Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
4.09/5 (3 votes)
See more:
#define BEGIN_MSG_MAP(theClass) \
public: \
BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
{ \
BOOL bHandled = TRUE; \
(hWnd); \
(uMsg); \
(wParam); \
(lParam); \
(lResult); \
(bHandled); \

switch(dwMsgMapID) \
{ \
case 0:
Posted

I'm going to try to synthesis three other answers which each have an important point.

There are situations where seemingly useless parenthesis are necessary for correctness in a macro definition. («_Superman_») In the cases that you have highlighted, however, they have no significant impact on how the preprocessor handles the code. (loyal ginger) The parenthesis are present as documentation to indicate that the "do nothing" expressions that will likely be optimized out by the compiler were put in for a reason. (me) That reason is to suppress compiler warnings about unused values. ( KarstenK )
 
Share this answer
 
to make the compiler silent about the unused values.

I make that BOOL ProcessWindowMessage(HWND /*hWnd*/,...

 
Share this answer
 
In my opinion, there is no need for the parenthsis around those variables. So from the compiler point of view, they are no different from those without parenthsis.

So to your question, why use parenthsis, the answer is "because he is crazy ;P !"
 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900