linux c 宏编译,linux c代码批量宏展开

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

#!/bin/sh

#expans all the macro in source file

INCLUDE=""

#get all the header files directory

function get_include()

{

for file_t in `ls -l $1|grep -E "^d|\.([ch]|cpp)$"|awk '{print $8}'`

do

if [ -d $1"/"$file_t ] #the file is a dir

then

if [ "$file_t" == "include" ]

then

INCLUDE=$INCLUDE" -I./"$1"/"$file_t

else

get_include $1"/"$file_t

fi

fi

done

export CFLAGS=$INCLUDE

}

function macro_expansion()

{

oldpath=$1

newpath=$2

if [ ! -d $newpath ]

then

mkdir $newpath

fi

if [ $? -gt 0 ]

then

exit

fi

if [ $3 -eq 0 ]

then

get_include $oldpath

echo $CFLAGS

fi

for file_t in `ls -l $1|grep -E "^d|\.([ch]|cpp)$"|awk '{print $8}'`

do

oldfile=$oldpath"/"$file_t

newfile=$newpath"/"$file_t

if [ -d $oldfile ] #the file is a dir

then

./expan_macro $oldfile $newfile 1

else

#echo $CFLAGS

gcc -E $CFLAGS $oldfile -o $newfile

fi

done

}

#Show help when script started without arguments

function showHelp()

{

echo "Usage: $0 source_dir dst_dir flag(be 0 all the time)"

echo "example:$0 src dst 0"

}

if [ ! $# -eq 3 ]

then

showHelp

exit

fi

macro_expansion $1 $2 $3

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

总结

以上是编程之家为你收集整理的linux c代码批量宏展开全部内容,希望文章能够帮你解决linux c代码批量宏展开所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值