In the C standard, there's this:
A parameter in the replacement list, ..., is replaced by the corresponding argument after all macros contained therein have been expanded.
It's in Section 6.10.x.x, last 2 subsections vary across editions. Section name "Argument Substitution".
The way I'm interpreting "after all macros contained therein have been expanded" is simply "ah yes, arguments are evaluated before the function call itself".
But I ran a few examples on my computer:
#define s(x) h(x) #define h(x) #x #define foo 123 h(foo) Terminal interaction:
$ cpp fundef.c # 1 "fundef.c" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 464 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "fundef.c" 2 #123 $ cc -E fundef.c # 1 "fundef.c" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 465 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "fundef.c" 2 "foo" $ cpp --version ; cc --version Apple clang version 17.0.0 (clang-1700.0.13.3) Target: arm64-apple-darwin24.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin Apple clang version 17.0.0 (clang-1700.0.13.3) Target: arm64-apple-darwin24.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin $ If macros in the arguments are replaced before they're substituted, shouldn't it end up in "123"? (Otherwise, the widely-known double-glue idiom in C wouldn't exist)
What's happenning here?
#or##preprocessing token or followed by a ## preprocessing token (see below)," that you edited out of the middle there seems pretty material. It's interesting thatcppandcc -Eare giving different output, but the quotation feels actively misleading with regard to what is being asked in the rest of the question. $\endgroup$