Creating .I file in C [closed]
开发者_StackOverflow社区
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this questionSir pls tell me how to create .I file (extended source file) in c
A common way to create files in C
is with the fopen()
function.
#include <stdio.h>
FILE *handle;
handle = fopen("extended.I", "w");
if (handle != NULL) {
/* ... */
fclose(handle);
}
Terribly vague question, but it sounds like you are using Visual Studio. Right-click your project, Properties, C/C++, Preprocessor, change "Generate Preprocessed File" to Yes.
After you rebuild, you'll get the .i files with the preprocessor output in your project directory.
arsane's comment is the correct response if you are on Linux. "To expand the macro, you can try
gcc -E -o main.I main.c
"
When using the gcc compiler system, it is possible to halt the compiler system at particular phases by using compiler flags. -E
for .i files, -S
for .s files (an assembly language version of the program)
From the gcc man page:
-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 which don't require preprocessing are ignored.
The following command will create a .i
file from a .c
file
cc -E main.c -o main.i
精彩评论