I'm new to C and am learning C from Programming in C, 4th ed. by Stephen Kochan. On page 29, he writes $ is not a valid character for variable names. He is using the C11 standard.
I wrote the following code
#include <stdio.h>
int main (void)
{
int a$ = 1;
printf ("%i", a$);
return 0;
}
and ran it with the command gcc -std=c11 -pedantic practice.c -o practice.o && ./practice.o. My filename is practice.c.
The output is 1. Shouldn't the compiler give me a warning for using $? Isn't using $ sign for identifiers an extension that GCC provides?
I'm using GCC 8.2.0 in Ubuntu 18.10.
Edit:
Also, doesn't GCC not use the GNU extensions when I use -std=c11? That is what is written in the Appendix of the book (pg. no. 497).
I am getting an warning by using -std=c89 though.
.oextension is usually used for object files, not for the final executable.practiceis correct. Check your/usr/bindirectory and you'll see that the programs there don't have an extension either.file practicefrom the command line I getpractice: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=928002f23b27d5c9bc55a15bf769edfaf3e62c23, not strippedfileutility can showshared objectfor an ELF executable if it is a position-independent executable. Some distributions configure GCC so that it creates position-independent executables by default (usually this requires using-pieand-fPICoptions).$after those that don't.