编译 c 预处理器输出
Compile c preprocessor output
我知道您可以直接使用 cpp 或通过 gcc -E 调用它来为输入文件生成预处理器输出。
但是,如果给定这样一个输出文件,我如何才能将其编译为目标代码或将其编译并 link 为可执行映像?
编辑:
整个问题显然是我没有提供我将 cpp 的输出重定向到 .c 扩展名的文件,而 gcc 不喜欢它。
how can I, given such an output file, compile it to object code or compile it and link it into an executable image?
通常,就像任何其他源文件一样,将其传递给 gcc
。
cpp input_file > output_file.c
gcc output_file.c
./a.out
我知道您可以直接使用 cpp 或通过 gcc -E 调用它来为输入文件生成预处理器输出。
但是,如果给定这样一个输出文件,我如何才能将其编译为目标代码或将其编译并 link 为可执行映像?
编辑: 整个问题显然是我没有提供我将 cpp 的输出重定向到 .c 扩展名的文件,而 gcc 不喜欢它。
how can I, given such an output file, compile it to object code or compile it and link it into an executable image?
通常,就像任何其他源文件一样,将其传递给 gcc
。
cpp input_file > output_file.c
gcc output_file.c
./a.out