I have a C project with many header files, but I do not want to deliver to the client one specific header file with bunch of defines. I want all other files to be preprocessed with just that specific header file, and I want to regenerate all sources to a new directory, so that client is able to compile this project's new source although he wouldn't have the mentioned header file.
我有一个包含许多头文件的C项目,但我不想向客户端提供一堆具有定义的特定头文件。我希望所有其他文件只使用该特定头文件进行预处理,并且我想将所有源重新生成到新目录,以便客户端能够编译该项目的新源,尽管他没有提到的头文件。
Is there a Linux or Windows way to do this without manual search/replace in editor?
在编辑器中没有手动搜索/替换,是否有Linux或Windows方法可以执行此操作?
1 个解决方案
#1
1
I would use a macro processing tool such as m4, which is widely available (it's standard on most Linux and *nix distributions, as it's used by autoconf, sendmail, et al). Convert the special header to a bunch of m4
macros and then apply this to all the source files.
我会使用宏处理工具,如m4,它是广泛可用的(它是大多数Linux和* nix发行版的标准,因为它由autoconf,sendmail等使用)。将特殊标头转换为一堆m4宏,然后将其应用于所有源文件。
Note that there are plenty of other alternatives to m4
, and scripting languages such as Perl could also be considered.
请注意,m4还有很多其他替代方法,也可以考虑使用Perl等脚本语言。
#1
1
I would use a macro processing tool such as m4, which is widely available (it's standard on most Linux and *nix distributions, as it's used by autoconf, sendmail, et al). Convert the special header to a bunch of m4
macros and then apply this to all the source files.
我会使用宏处理工具,如m4,它是广泛可用的(它是大多数Linux和* nix发行版的标准,因为它由autoconf,sendmail等使用)。将特殊标头转换为一堆m4宏,然后将其应用于所有源文件。
Note that there are plenty of other alternatives to m4
, and scripting languages such as Perl could also be considered.
请注意,m4还有很多其他替代方法,也可以考虑使用Perl等脚本语言。