Standard defined macros
To know the standard macros defined by the compiler, simply run:
gcc -dM -E - < /dev/null
$ gcc -dM -E - < /dev/null | grep __STDC_VERSION__ #define __STDC_VERSION__ 201112L
Don’t use standard include files
In some cases, an application has to be self contained ie. no other files
are needed to compile it. To be sure that
gcc doesn’t use the system
header files, the option
-nostdinc can be used :
Do not search the standard system directories for header files. Only the directories you have specified with -I options (and the directory of the current file, if appropriate) are searched.
See also more preprocessor options.
When studying an application that comes from Windows, there can be some mismatch between the names of the included files and their names on the system. It can work on Windows because the file system is case-insensitive.
The correct way to fix the problem is to change the source code, but in some cases, this can be forbidden.
A workaround is to use the
-remap that makes possible
to provide a file, that must be named
header.gcc, to give the match between
the include name and the file name.
How to do
Suppose that you have a source directory
srcs and an include directory
build the list of all the files :
find the names of the included files (supposed to be between
INCL=$(grep 'include *"' $SRCS | sed 's=.*"\(.*\)".*=\1=' | sort -u )
Adapt the regexp for more complex cases.
find the file(s) for each included header :
for f in $INCL ; do FILES=$(find includes/ -iname $f) if [ -z "$FILES" ] ; then echo "ERROR: $f not found" 1>&2 else if [ $(echo $FILES | wc -l) -ne 1 ] ; then echo "ERROR: found more then one $f : $FILES" 1>&2 else if [ "$f" != "$FILES" ] ; then echo "$f $FILES" fi fi fi done
- the result of the script can be redirected to
header.gccbut the errors have to be fixed.
WARNING: this has to be fixed. The
header.gcc file has to be in each source directory to make
Wrong file extension
When studying a C application that comes from Windows,
it can be the case that some files have the extension
because Windows file system is case-insensitive (see above).
gcc use the file extension to guess its kind,
and concludes that
.C files are
-x c forces it to consider them as C code.
Voir aussi :
- Afficher un pourcentage dans une page HTML
- VNC : Virtual Network Computing
- Git : déménagement d'un dépôt
- Quelques liens au sujet de l'analyse statique
- Ocaml: mon principal langage de développement
- Disque dur externe
- Les profiles dans Firefox
- Cryptographie et mail sous Android
- Quelques liens au sujet du C
- Git rebase : pour diviser un commit