1

I am implementing a C preprocessor...

On Wiki, I found the following functionalities of it...

  • Trigraph replacement
  • Line splicing
  • Tokenization
  • Macro expansion and directive handling
  • File Inclusion

My questions:

  • Am I missing any functionality?
  • What is the correct sequence of execution of the above functionalities? (i.e. what is done before what in today's practical preprocessors?)

If anyone knows any standard doc' about it, please mention that too.

2 Answers 2

7

The standard doc is the C standard! The official versions are non-free, but you can find drafts that are sufficiently accurate, e.g. http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf for C99.

The chapters of interest are 5.1.1.2 (Translation phases) and 6.10 (Preprocessing directives).

Sign up to request clarification or add additional context in comments.

1 Comment

If you are at it, probably best is to also look at the current standard, C11, and not only C99. I don't think that much has changed, but you never know. This would be '1570' instead of '1256'.
2

You may want to check out the gcc docs to see how they implement it: http://gcc.gnu.org/onlinedocs/cpp/

You could also have a look at the source code for gcc: http://www.gnu.org/software/gcc/releases.html

Hope this helps

1 Comment

Thanks! Can you please tell me where to look for the C preprocessor code inside the huge(I mean extremely huge!) source code folder?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.