Страница 1 из 1

Как получить вывод программы на С после препроцессора?

Добавлено: 18 ноя 2020, 17:09
Restart1566
Всем доброго вечера!

Порылся в man - не нашел.
Подскажите, пожалуйста!

Как получить вывод программы на С после препроцессора?

Добавлено: 18 ноя 2020, 17:12
rogoznik
Restart1566, а давай ты полностью опишешь задачу.

Как получить вывод программы на С после препроцессора?

Добавлено: 18 ноя 2020, 19:51
WWolf
Restart1566 писал(а):
18 ноя 2020, 17:09
Порылся в 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.

Как получить вывод программы на С после препроцессора?

Добавлено: 19 ноя 2020, 09:00
Restart1566
WWolf писал(а):
18 ноя 2020, 19:51
man gcc строка 687, ключ -E оно?
Нет. Собственно, мне нужен ИСХОДНЫЙ ТЕКСТ программы после обработки препроцессором. Раскрытые определения и макроопределения.

Как получить вывод программы на С после препроцессора?

Добавлено: 19 ноя 2020, 10:42
WWolf
Restart1566, что значит нет?
тестовый файл

Код: Выделить всё

#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;
}

Как получить вывод программы на С после препроцессора?

Добавлено: 19 ноя 2020, 11:29
Restart1566
WWolf писал(а):
19 ноя 2020, 10:42
выхлоп
Да!
Прошу прощения, не дочитал в спешке...

СПАСИБО!!!