linux gcc 预编译

linux gcc 预编译
命令:gcc -E test.c -o test.i

 

预编译主要完成以下功能:
1.删除所有的注释“//”和“/**/”;
2.删除所有的“#define”,展开所有的宏定义;
3.处理所有的条件预编译指令;
4.处理“#include”预编译指令,将被包含的文件插入到该预编译指令的位置,这一过程是递归进行的;
5.添加行号和文件名标识;

 

例:

源文件(test.c)如下:

#include <stdio.h>

#define MY_SIZE 1000000

//this is a test
/*this
is
a
test
!
*/

int main(int argc,char* argv[])
{
    char *test=NULL;
    while(1)
    {
        test = NULL;
        test = new char[MY_SIZE];
        if(test == NULL)
        {
            printf("I am wrong/n");
            break;
        }
        printf("a../n");
    }
    printf("I am ok!/n");
    return 0;
}

 

预编译后文件内容(test.i)如下:

。。。//此处略过一大段头文件插入内容

extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__)) ;


extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__));
# 850 "/usr/include/stdio.h" 3 4

# 2 "abc.c" 2
# 13 "abc.c"
int main(int argc,char* argv[])
{
    char *test=((void *)0);
    while(1)
    {
        test = ((void *)0);
        test = new char[1000000];
        if(test == ((void *)0))
        {
            printf("I am wrong/n");
            break;
        }
 printf("a../n");
    }
    printf("I am ok!/n");
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值