#define WNDWIDTH 400;
#define WNDHEIGHT 400;
#define WNDTYPE WS_OVERLAPPEDWINDOW;
const char g_szClass[] = "FrameClass";
const char g_szCaption[] = "FrameCaption";
The example was taken from the RPG book and I'm just wondering why the author did that.
Thanks guys!
quiggy.
What does ... mean?
I'm reading through Programming RPG's with DirectX and I'm puzzled by a function call.
void AppError(BOOL Fatal, char *Text, ...);
I've seen this '...' in some other stuff as well, but have never seen an explanation for what it means.
It has to be some sort of variable I'm presuming, but I have no idea what it could be. Can anybody enlighten me?
Also one more thing. I know what the difference is between using the old #define preprocessor and the newer const command. But why would you use both as in the example below? Shouldn't you always use const?
WRT your first question, ''...'' is a variable argument list. You can put in as many variables as you want of any type. This is a good explanation.
Here''s the answer to the second question
say you had this
#define WNDWIDTH 400;
when the compiler encountered WNDHEIGHT it would replace it with 400
if you have this
const char g_szClass[] = "FrameClass";
Then when your compiler see''s g_szClass it tells the computer where in memeory the string "FrameClass" would be located. This means that "FrameClass" would have to be stored once in the exe file and then all the code that wants it would just have a pointer to it. With the define above however the 400 gets stored everywhere it is used.
Hopefully that made sense
say you had this
#define WNDWIDTH 400;
when the compiler encountered WNDHEIGHT it would replace it with 400
if you have this
const char g_szClass[] = "FrameClass";
Then when your compiler see''s g_szClass it tells the computer where in memeory the string "FrameClass" would be located. This means that "FrameClass" would have to be stored once in the exe file and then all the code that wants it would just have a pointer to it. With the define above however the 400 gets stored everywhere it is used.
Hopefully that made sense
Thanks for the link ze_jackal. Exactly what I needed...
And thanks to Mondar for the DEFINE refresher course. :-) It''s nice to see what exactly is going on behind the scene.
Quiggy.
And thanks to Mondar for the DEFINE refresher course. :-) It''s nice to see what exactly is going on behind the scene.
Quiggy.
It''s called an ELLIPSIS.
It specifies like said a variable number of arguments to the function.
You use the va_xxx functions to work with the ellipsis to get the data off the stack frame.
Functions like printf use this so you can supply a variable number of arguments to the function.
It specifies like said a variable number of arguments to the function.
You use the va_xxx functions to work with the ellipsis to get the data off the stack frame.
Functions like printf use this so you can supply a variable number of arguments to the function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement