Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"#ifdef" inside a macro [duplicate]

Possible Duplicate:
#ifdef inside #define

How do I use the character "#" successfully inside a Macro? It screams when I do something like that:

#define DO(WHAT)        \ #ifdef DEBUG        \                              MyObj->WHAT()         \        #endif              \ 
like image 396
JasonGenX Avatar asked Aug 30 '11 16:08

JasonGenX


People also ask

What do 2 quotation marks mean?

Double quotation marks are used for direct quotations and titles of compositions such as books, plays, movies, songs, lectures and TV shows. They also can be used to indicate irony and introduce an unfamiliar term or nickname. Single quotation marks are used for a quote within a quote.

What is quotation mark used for?

The primary function of quotation marks is to set off and represent exact language (either spoken or written) that has come from somebody else. The quotation mark is also used to designate speech acts in fiction and sometimes poetry.

What is the 1 quotation mark called?

Single quotation marks are also known as 'quote marks', 'quotes', 'speech marks' or 'inverted commas'. Use them to: show direct speech and the quoted work of other writers. enclose the title of certain works.

What is the difference between 1 and 2 quotation marks?

If you are an American, using quotation marks could hardly be simpler: Use double quotation marks at all times unless quoting something within a quotation, when you use single. It's different in the greater Anglosphere, where they generally use singles in books and doubles in newspapers.


1 Answers

You can't do that. You have to do something like this:

#ifdef DEBUG #define DO(WHAT) MyObj->WHAT() #else #define DO(WHAT) do { } while(0) #endif 

The do { } while(0) avoids empty statements. See this question, for example.

like image 125
Roger Lipscombe Avatar answered Nov 05 '22 04:11

Roger Lipscombe