![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Posts: 22
Rep Power: 0
![]() |
Help with this. Can you check what's missing?
on this line
#define DO_INIT_STRUCT(ddstruct) { memset (&ddstruct, 0 , sizeof(ddstruct)); ddstruct.dwSize = sizeof(ddstruct); } What is missing up there? Cuz I kept getting an error error C2447: missing function header (old-style formal list?) Thxs ![]() |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,224
Rep Power: 5
![]() |
You really need to read the "How to post a question" sticky thread at the top of the C++ forum. That gives useful advice on how to ask questions to increase your chances of getting a useful answer.
That said, you got lucky..... this time. The answer to your question is that macros only work on one line by default. If you want a macro to work across multiple lines, you need to use a "continuation marker" so the preprocessor knows that what you intend. The "continuation marker" is a backslash on the end of ALL except the last line of the macro. #define DO_INIT_STRUCT(ddstruct) \
{ \
memset (&ddstruct, 0 , sizeof(ddstruct)); \
ddstruct.dwSize = sizeof(ddstruct); \
}If you want to be safer, you will actually do something like this; #define DO_INIT_STRUCT(ddstruct) \
do { \
memset (&ddstruct, 0 , sizeof(ddstruct)); \
ddstruct.dwSize = sizeof(ddstruct); \
} while(0)if (some_condition) DO_INIT_STRUCT(some_struct); else do_something_else(); |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2006
Posts: 22
Rep Power: 0
![]() |
sorry grumpy i didnt know how this forum systemw works and i did not intentionally do it on purpose. forgive me. but thxs for helping me out. Your a nice guy. Anyways, I will go and take a look through the rules of how to post....
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|