Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does an empty # mean in a macro definition?

Tags:

c++

c

macros

I have the following macro:

#define F(Args, ...) \
   // macro definition
#
   F(()) // looks like usage?
#undef F

What does the line containing only # mean? Is F(()) a usage of the macro?

like image 984
embedc Avatar asked Feb 02 '19 10:02

embedc


1 Answers

Technically, that's not part of the macro (no continuation line before it). It's a directive that comes after the #define directive.

# on its own line is called a null directive and it does nothing (as good as a comment).

It's no longer practically useful (except as a visual marker) but in prehistoric C, the preprocessor only got invoked if a C source file started with a directive and the null directive placed at the very beginning of a C file was a good way to make sure the file was preprocessed (i.e., that later directives worked) without starting with a concrete directive.

like image 169
PSkocik Avatar answered Oct 18 '22 16:10

PSkocik