gpt4 book ai didi

c-preprocessor - 将 C 预处理器用于 C 以外的语言

转载 作者:行者123 更新时间:2023-12-03 14:39:42 25 4
gpt4 key购买 nike

C Preprocessor 的维基百科条目状态:

The language of preprocessor directives is agnostic to the grammar of C, so the C preprocessor can also be used independently to process other types of files.



如何才能做到这一点?有什么例子或技巧吗?

编辑:是的,我最感兴趣的是宏处理。即使它可能不是可取的或不可维护的,但知道什么是可能的仍然很有用。

最佳答案

您可以直接调用 CPP:

cpp <file>

而不是通过 gcc 调用它:
gcc -E filename

但是请注意,正如在同一篇 Wikipedia 文章中所提到的,C 预处理器的语言并没有真正用于通用用途:

However, since the C preprocessor does not have features of some other preprocessors, such as recursive macros, selective expansion according to quoting, string evaluation in conditionals, and Turing completeness, it is very limited in comparison to a more general macro processor such as m4.



您是否考虑过使用更灵活的宏处理语言,例如前面提到的 m4?

关于c-preprocessor - 将 C 预处理器用于 C 以外的语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1099843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com