Why does the C preprocessor insert an extra space?

Viewed 47

When I run the C preprocessor on this source file:

1+1 1-1
A+1 A-1
A+A A-A
#define A 1
A+1 A-1
A+A A-A

I get this output with clang -E -P:

1+1 1-1
A+1 A-1
A+A A-A

1 +1 1 -1
1 +1 1 -1

And almost exactly the same output with gcc -E -P:

1+1 1-1
A+1 A-1
A+A A-A
1 +1 1 -1
1 +1 1 -1

I know the behavior of the C preprocessor used as a stand alone tool is not specified by the C Standard, but what is the reason for both gcc and clang to insert an extra space after the expansion of the macro A when followed by a + or a - operator?

0 Answers
Related