Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法遍历所有包含/定义的头文件,然后#undef全部?
#undef
如果循环是问题,还有其他方法可以#undef轻松解决所有问题吗?
GNU cpp 提供了一个 -dM 指令来做到这一点,您可以列出所有定义:
gcc -E -dM -c foo.c
然后,您可以使用 sed 脚本在命令行上取消定义它们:)
gcc -E -c foo.c | sed 's/#define/#undef/'
或做任何事...
玩得开心 :)