Your compiler is useful, treating printf specifically as inline.
Example code "tst.cpp":
int printf(char const *format,...); int foo(int a, char const *b); int main() { printf("Hello, World!"); foo(42, static_cast<char const *>("Hello, World!")); return 0; }
When compiling with the Microsoft cl compiler command "cl / c tst.cpp", we can check the resulting .obj and find:
00000000 r $SG2552 00000010 r $SG2554 00000000 N .debug$S 00000000 i .drectve 00000000 r .rdata 00000000 t .text$mn U ?foo@ @ YAHHPBD@Z U ?printf@ @YAHPBDZZ 00e1520d a @comp.id 80000191 a @feat.00 00000000 T _main
Note that both foo () and printf () are garbled.
But when we compile with / usr / lib / gcc / i 686-pc-cygwin / 3.4.4 / cc1plus.exe via cygwin "g ++ -c tst.cpp", we get:
00000000 b .bss 00000000 d .data 00000000 r .rdata 00000000 t .text U __Z3fooiPKc U ___main U __alloca 00000000 T _main U _printf
Here foo () is distorted, but printf () is not, because the cygwin compiler is useful. Most of them consider this to be a compiler defect. If the cygwin compiler is called using "g ++ -fno-builtin -c tst.cpp", the problem disappears and both characters are garbled, as it should be.
The more current g ++ is correct, with compilation with / usr / libexec / gcc / i 686-redhat-linux / 4.8.3 / cc1plus via "g ++ -c tst.cpp" we get:
00000000 T main U _Z3fooiPKc U _Z6printfPKcz
Both foo () and printf () are garbled.
But if we declare printf such that cygwin g ++ does not recognize it:
char const * printf(char const *format,...); int foo(int a, char const *b); int main() { printf("Hello, World!"); foo(42, static_cast<char const *>("Hello, World!")); return 0; }
Then both foo () and printf () are distorted:
00000000 b .bss 00000000 d .data 00000000 r .rdata 00000000 t .text U __Z3fooiPKc U __Z6printfPKcz U ___main U __alloca 00000000 T _main