I have a little problem with the preprocessor that puzzles me, and I cannot find any explanation for this in the documentation / preprocessor / language specification.
#define booboo() aaa booboo()bbb booboo().bbb
pre-processed in:
aaa bbb <--- why is space added here aaa.bbb
After processing trigrams, continued lines, and comments, the preprocessor works on the preprocessor directives and divides the input into preprocessing tokens and spaces. The booboo replacement list contains one pp token, which is the identifier "aaa". booboo () bbb is divided into pp tokens: "booboo", "(',')", "bbb". The sequence 'booboo', '(', ')' is recognized as a macro function call and should be expanded to 'aaa', and imho in the view should look like aaabbb. I said that from then on - for a person - it will look like a single token, while the compiler will get 2 tokens βaaaβ and βbbbβ, since the operator ## was not used, which allows the concatenation of pp-token. Why / what rule does cpp (c preprocessor) put extra space between 'aaa' and 'bbb' when 'booboo (). Does bbb 'result in' aaa.bbb 'without a space?
Is it because cpp is trying to make a conclusion (which is mostly for people) unambiguous? A person cannot say that "aabb" consists of two tokens, since he sees only spelling. I'm right? I read the C99 documentation on the preprocessor and gcc documentation for cpp. I donβt see anything about it.
If I am right, we have a similar situation:
#define baba() + baba()+ baba()-
leads to:
+ + +-
Otherwise (if β++β is the output), it will look like a person similar to the β++β token, but there will be two tokens β+β and β+β. It seems that with the operator '##', that cpp checks to see if the concatenation gives a valid token, but in the cases shown it wants the person not to perform this concatenation? '+ -' is not ambiguous, so no space is added
c ++ c c-preprocessor
Artur
source share