you can also use gcc -v
command that works like gcc --version
and if you would like to now where gcc
is you can use whereis gcc
command
I hope it'll be usefull
gcc -dumpversion
-dumpversion
Print the compiler version (for example,3.0
) — and don't do anything else.
The same works for following compilers/aliases:
cc -dumpversion
g++ -dumpversion
clang -dumpversion
tcc -dumpversion
Be careful with automate parsing the GCC output:
--version
might be localized (e.g. to Russian, Chinese, etc.)--version
output will contain something like Android (5220042 based on r346389c) clang version 8.0.7
(it's real version string)The answer is:
gcc --version
Rather than searching on forums, for any possible option you can always type:
gcc --help
haha! :)
#include <stdio.h>
int main() {
printf("gcc version: %d.%d.%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
return 0;
}
Source: Stackoverflow.com