java
sql
html
iphone
css
c
python
mysql
database
xcode
ruby-on-rails
objective-c
multithreading
flash
algorithm
oracle
cocoa
apache
mvc
php5
The preprocessor performs literal substitution with all macros.
Therefore, if you define an "empty" macro, then each place that identifier appears in your code will be replaced with an empty statement by the preprocessor before the compiler ever runs.
So yes. No code will be generated for the example given in your question.
That's correct. Your code expands to
;
after preprocessing.
Note that you can ask your compiler to show you the code after preprocessing (in gcc, this is the -E option; your compiler may vary).
-E
You're absolutely correct, the empty macro doesn't generate any code.
I've seen two places where this is useful. The first is to eliminate warnings when a function parameter isn't used:
#define UNUSED(x) int foo(int UNUSED(value)) { return 42; }
The second is when you use conditionals to determine if there should be code or not.
#ifdef LOGGING_ENABLED #define LOG(x) log_message(x) #else #define LOG(x) #endif