Thread: Declaration confusion

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    43

    Declaration confusion

    Hi all

    I'm learning to use Direct3D and DirectX at the moment, and I've come across a piece of code I'm a little confused by, could anyone clarify what the below is doing:

    (BYTE**) &pVertices // pVertices is a void pointer

    I can see roughly the effect it is having on the program, however I'm a little confused as to what it's actually doing. Any help would be appreciated cheers!

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    344
    It's taking the address of pVerticies, making the value a pointer to a pointer. It's then saying that this pointer to a pointer is not void **, but BYTE ** instead. I'd need more context to know why it's doing that. Perhaps the code is passing the pointer into a function by reference so changes to it can be returned to the caller?

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    5
    pointers to pointers always confuse me lol

  4. #4
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    Its basically casting the void pointer to a byte pointer. But since your getting the address of pVertices which is already a pointer, the value returned would be a pointer to a pointer. Hence you need to cast it to a pointer to pointer to byte.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Pointers to pointers need not confuse you.
    Say, you have an int. To modify it, you need to pass a pointer to the int to a function.
    Now say you have a pointer to int (int*). To modify it, you need to pass a pointer to that variable; thus it becomes a pointer to (the) pointer to int.

    First case:
    Variable to modify: int x;
    Argument by function: int * px;

    Second case:
    Variable to modify: int * x;
    Argument by function: int* * px;

    Simple, really.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM