0

I am currently reading: enter link description here -Which is gcc the C preprocessor documentation.

But still even if I look for other documentations, I am not able to find the true macro implementation. A have found a exe:cc1 file in /usr/lib/gcc/x86_64-linux-gnu/8/cc1, which should be used in a phase (do not know which one) of compiling according to this: enter link description here But in what language is actually preprocessor implemented, I mean - it is historically older then c , so I would suppose assembler or similar. The main reason for this is, How can I implement or extend it by my own directives. Some suggests to use quick perl program to do this for me before compilation by gcc, but I am still wondering where to find files of preprocessor implemented in c in linux (if exists in c source file and not elf file or already as object file - as cc1 does - then I am not able to read the implementation of course. I would be also glad if anyone can mention that phase of macro preprocessing (not asking about explanation of individually directives, rather how it inner does it job). I just want to look in its intestines.

Herdsman
  • 799
  • 1
  • 7
  • 24
  • The preprocessor is not a separate application that you can modify or extend. It would break the principle that an app should build in different compilers. You can do your own, as suggested, but it would be a risky practice. – john elemans Dec 13 '19 at 17:56
  • @john - it could, but if there is a need to extend current cpp then why not? Anyway, that doesnt answer to HOW to actually modifie the cpp. – Herdsman Dec 13 '19 at 18:07

1 Answers1

0

It whatever the programmer decided. You can implement a preprocessor in any language.

You should avoid changing how the preprocessor behaves, because that makes your programs not C anymore.

The source code for GCC's preprocessor is found in the GCC repository, along with everything else, and it is currently written in C.

Acorn
  • 24,970
  • 5
  • 40
  • 69
  • so where can I find the gcc repository then? In file system somewhere or github? – Herdsman Dec 13 '19 at 18:05
  • https://gcc.gnu.org/svn.html (from the gcc "about" page here: https://gcc.gnu.org/svn.html ). The first gcc release was apparently in 1987 ( https://gcc.gnu.org/releases.html ) so it predates git (and svn for that matter). – jgreve Dec 13 '19 at 18:11
  • @Herdsman There are many mirrors. A simple visit to GCC's webpage is enough :) -- where jgreve has linked. Your Linux distribution typically also has the exact source code that was used to build the version they provide in a package that you can download. – Acorn Dec 13 '19 at 18:13