I try to print "Linux is number linux" in C language with C preprocessor, but it always print "Linux is number 1". It only happened with GCC, not tinycc.
Expected: Linux is number linux! Actually: Linux is number 1!
Below Dockerfile is just for testing between different compiler and version easier. I have tried GCC version 4.9.4, 5.5.0, 6.5.0, 7.5.0, 8.5.0, 9.5.0, 10.2.0, 10.5.0, 11.4.0, 12.3.0 and 13.1.0. it will print something like below.
gcc (GCC) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Linux is number 1!
tcc version 0.9.27 mob:afc1362 (x86_64 Linux)
Linux is number linux!
linux1.c
#include <stdio.h>
#define stringify_x(x) #x
#define STRINGIFY(s) stringify_x(s)
int main(void)
{
printf(STRINGIFY(Linux is number linux!\n));
return 0;
}
Dockerfile
FROM gcc:13.1.0
COPY . /usr/src/linux1
WORKDIR /usr/src/linux1
RUN gcc -o linux1 linux1.c
CMD ["/bin/bash", "-c", "/usr/local/bin/gcc --version; ./linux1"]
Dockerfile
FROM bensuperpc/tinycc:20220726-97fe2cc
COPY . /usr/src/linux1
WORKDIR /usr/src/linux1
RUN tcc -o linux1 linux1.c
CMD ["/bin/sh", "-c", "tcc --version; ./linux1"]