0

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?

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

Michal Hromas
  • 75
  • 1
  • 7
  • Their syntax is a part of the language (at least the standard ones). – Eugene Sh. May 01 '18 at 13:35
  • 1
    They are part of the compiler tool suite, and always have been. Nothing to do with an IDE. –  May 01 '18 at 13:35
  • https://stackoverflow.com/tags/c-preprocessor/info – Stargateur May 01 '18 at 13:36
  • So it's a part of the compiler not a standalone program? – Michal Hromas May 01 '18 at 13:38
  • 2
    It doesn't matter. Every toolchain can implement it as they wish. – Eugene Sh. May 01 '18 at 13:39
  • See my answer to this question for an historical perspective: https://stackoverflow.com/questions/45629176/why-do-all-the-c-files-written-by-my-lecturer-start-with-a/45629209#45629209 – Bathsheba May 01 '18 at 13:56
  • 1
    Any C or C++ compiler will either have its own internal preprocessor or come bundled with a preprocessor that it invokes. In addition to that, an IDE is likely to include the ability to expand macro definitions since that would be useful for debugging, so the fact that the compiler will have a preprocessor doesn't mean that an IDE can't have it own preprocessor. In addition, an IDE can have its own custom preprocessor e.g. [code blocks](http://wiki.codeblocks.org/index.php/Variable_expansion) has one. – John Coleman May 01 '18 at 13:57

2 Answers2

3

The earliest work on the language that will some years later get the name "C" began in 1969, based on the language BCPL. Preprocessor came to life in 1972.

The C was at that time still work in progress, so we can say that preprocessor existed since the C itself. There was never a C compiler without the preprocessor.. C++ came to life after C, and it had the preprocessor from the start.

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.


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. Its original version was exceedingly simple, and provided only included files and simple string replacements: #include and #define of parameterless macros. Soon thereafter, it was extended, mostly by Mike Lesk and then by John Reiser, to incorporate macros with arguments and conditional compilation. 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.

BJovke
  • 1,737
  • 15
  • 18
1

No, preprocessors are part of compiler. If you compile from console (i.e. using gcc or other compiler directly), preprocessing will still work.

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.