linux c语言头文件 在另外的地方,linux下编c语言头文件的问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

但我发现windows下的头文件在linux下不能用,是很正常的!

批量编译GCC的C源程序:

#include 

#include 

#include 

#include 

#include 

char *c="c";

char *cpp="cpp";

char *dot=".";

char *dotdot="..";

char *getfilename(char    *fullname){

char retname[256];

char *q=rindex(fullname,'.');  //从p中找到.出现的位置,此后q=".bin"

strncpy(retname,fullname,q-fullname); //把p与q之间的字符复制给s,此后s="234"

retname[q-fullname]='\0'; //在s数字字符串的末尾加上null

return retname;

}

void    do_search_dir(char    *path)    {

DIR    *dir;

char    fullpath[1024],currfile[1024];

struct    dirent    *s_dir;

struct    stat    file_stat;

strcpy(fullpath,path);

dir=opendir(fullpath);

while    ((s_dir=readdir(dir))!=NULL)    {

if    ((strcmp(s_dir->d_name,dot)==0)||(strcmp(s_dir->d_name,dotdot)==0))

continue;

sprintf(currfile,"%s/%s",fullpath,s_dir->d_name);

stat(currfile,&file_stat);

if    (S_ISDIR(file_stat.st_mode))

do_search_dir(currfile);

else if(strstr(currfile+2,dot))

{

char gcc[512]="gcc ";

char o[256]=" -o ";

char *p=currfile;

while(*p)p++;

while(p>currfile && *p!='.')p--;

if (p!=currfile)p++;

strcat(gcc,currfile);

strcat(o,getfilename(currfile));

if((p-currfile+1==strlen(currfile) && strncmp(p,c,1)==0) || (p-currfile+3==strlen(currfile) && strncmp(p,cpp,3)==0))

{

sprintf(currfile,"%s%s",gcc,o);

system(currfile);

}

}

}

closedir(dir);

}

int    main()    {

do_search_dir(dot);

return 0;

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值