简体   繁体   English

预处理器IDE仅功能吗?

[英]Is the preprocessor IDE only feature?

I tried to do my research but wasn't able to find where preprocessors actually come from - are they part of the IDE's (meaning every IDE has its own implementation of it), standalone programs or part of the compilers? 我尝试进行研究,但无法找到预处理器的真正来源-它们是IDE的一部分(意味着每个IDE都有其自己的实现),独立程序还是编译器的一部分?

If they are became part of the modern compilers I imagine it didn't use to be this way historically. 如果他们成为现代编译器的一部分,我想它在历史上就没有用过这种方式。 How it worked back then? 那它是如何工作的呢?

Thank you 谢谢

The earliest work on the language that will some years later get the name "C" began in 1969 , based on the language BCPL . 在语言最早的工作,将一些年后得到名字“C”开始于1969年 ,基于语言BCPL。 Preprocessor came to life in 1972 . 预处理器于1972年问世

The C was at that time still work in progress, so we can say that preprocessor existed since the C itself. 当时C仍在进行中,因此可以说预处理器自C本身就已存在。 There was never a C compiler without the preprocessor. 没有预处理器,就没有C编译器。 . C++ came to life after C, and it had the preprocessor from the start. C ++在C之后诞生,并且从一开始就拥有预处理器。

It's irrelevant if the preprocessor was a separate executable file than the compiler but usually it's a part of the compiler. 预处理程序是不是编译器的独立可执行文件是无关紧要的,但通常它是编译器的一部分。 And no IDEs existed at that time. 那时还没有IDE。


Here's a link where you can read more. 这是您可以阅读更多内容的链接 This is the part about the preprocessor: 这是关于预处理器的部分:

Many other changes occurred around 1972-3 , but the most important was the introduction of the preprocessor , partly at the urging of Alan Snyder [Snyder 74], but also in recognition of the utility of the the file-inclusion mechanisms available in BCPL and PL/I. 1972-3左右发生了许多其他变化,但最重要的是预处理器的引入,部分是在Alan Snyder的敦促下[Snyder 74],但也认识到BCPL和Windows XP中可用的文件包含机制的实用性。 PL / I。 Its original version was exceedingly simple, and provided only included files and simple string replacements: #include and #define of parameterless macros. 它的原始版本极其简单,仅提供包含的文件和简单的字符串替换:#include和#define无参数宏。 Soon thereafter, it was extended, mostly by Mike Lesk and then by John Reiser, to incorporate macros with arguments and conditional compilation. 此后不久,主要由Mike Lesk和John Reiser对其进行了扩展,以将宏与参数和条件编译结合在一起。 The preprocessor was originally considered an optional adjunct to the language itself. 预处理器最初被认为是语言本身的可选附件。 Indeed, for some years, it was not even invoked unless the source program contained a special signal at its beginning. 确实,多年来,它甚至没有被调用,除非源程序在开始时就包含特殊信号。 This attitude persisted, and explains both the incomplete integration of the syntax of the preprocessor with the rest of the language and the imprecision of its description in early reference manuals. 这种态度持续存在,并解释了预处理器的语法与其他语言的不完全集成以及早期参考手册中对其描述的不精确性。

No, preprocessors are part of compiler. 不,预处理器是编译器的一部分。 If you compile from console (ie using gcc or other compiler directly), preprocessing will still work. 如果您从控制台进行编译(即直接使用gcc或其他编译器),则预处理仍将起作用。

Preprocessing is such a powerful tool that I believe it has always been part of compiler. 预处理是如此强大,我相信它一直是编译器的一部分。 Or if some early compilers lacked this feature - well, one had to do preprocessor's work manually. 或者,如果某些早期的编译器缺少此功能-那么,必须手动进行预处理器的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM