Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I figure out what is the default standard used by my C compiler GCC ? [duplicate]

Tags:

c

gcc

c99

c89

c11

Everything is in the title, I searched a lot but cannot find what is the standard that uses my compiler is it C89 C90 C99 or C11 ... I mean when we do not specify the -std option ( the default one) ?

like image 427
user12448 Avatar asked Dec 15 '22 17:12

user12448


1 Answers

When in doubt, consult the documentation. The gcc man-page makes it clear that -std=gnu89 is the default for C code, and -std=gnu++98 is the default for C++ code. The meaning of these options is described both in the man page and, in much more detail, in the extensive info documentation that is also available online.

These defaults for these flags have changed before and will change again, so it is best to check before assuming specific values.

UPDATE
The defaults have changed over the years. As of GCC 8.3.0, released in February 2019, the default standard for C is -std=gnu11, and -std=gnu++14 for C++. To be sure, look at the documentation of the compiler version you are actually using.

like image 115
user4815162342 Avatar answered Dec 29 '22 08:12

user4815162342