Why? Because the C preprocessor is agnostic of the C language!
The C preprocessor has been conceived as a pure text replacement tool, barely powerful enough to provide C programmers with a simple means to
define constants that are pasted literally into the program
literally paste the contents of files (i.e. headers) into the program
provide a simple means of creating simple templates of code, that are again pasted literally into the program
None of this includes any awareness of the C syntax! It's pure text manipulation.
On the contrary, you can do stuff like this
#define CLASS(name, base) typedef struct name name;\
struct name {\
base super;
#define END_CLASS };
CLASS(foo, bar)
int baz;
END_CLASS
Note how the preprocessor will generate an unmatched {
token when expanding the CLASS
macro, and an unmatched }
token when expanding the END_CLASS
macro.
Thus, the syntax for using a macro has nothing to do with the syntax for calling a function. You can call a C function in many different ways (foo()
, foo ()
, (foo)()
, (**(*foo) ) ()
, etc.) because the C language handles expressions of functions, and defines what happens when you place its name in parentheses (it's implicitly converted to a pointer to it), dereference it, or call it. All this does not exist in the preprocessor, so there is exactly one way to use a macro: foo()
with no extra space between the name and the (
.
Side note:
The C preprocessor is so agnostic of the C language, that it's not just used with C, it's also commonly used with languages like FORTRAN. (Which is a horrible fit, actually. Nevertheless, the C preprocessor is the best, commonly supported thing that can be used to make FORTRAN a bit less painful.)