Как получить вывод программы на С после препроцессора?
Добавлено: 18 ноя 2020, 17:09
Всем доброго вечера!
Порылся в man - не нашел.
Подскажите, пожалуйста!
Порылся в man - не нашел.
Подскажите, пожалуйста!
man gcc
строка 687, ключ -E
оно?
Код: Выделить всё
If you only want some of the stages of compilation, you can use -x (or filename suffixes) to tell gcc where to start, and
one of the options -c, -S, or -E to say where gcc is to stop. Note that some combinations (for example, -x cpp-output
-E) instruct gcc to do nothing at all.
-c Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is
in the form of an object file for each source file.
By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o.
Unrecognized input files, not requiring compilation or assembly, are ignored.
-S Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for
each non-assembler input file specified.
By default, the assembler file name for a source file is made by replacing the suffix .c, .i, etc., with .s.
Input files that don't require compilation are ignored.
-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source
code, which is sent to the standard output.
Input files that don't require preprocessing are ignored.
Код: Выделить всё
#define d1 10
#define d2 5
#define d3 d1/d2
int main()
{
int a;
a = d1;
a = d2;
a = d3;
return 0;
}
Код: Выделить всё
$ gcc -E test.c
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "test.c"
int main()
{
int a;
a = 10;
a = 5;
a = 10/5;
return 0;
}