2

I want to preprocess files before gcc actually does its own preprocessing and parsing. Actually this is my problem:

I have nonstandard extension added to a c++ .h file, which gcc wont understand, so i must preprocess this non-standard extensions into standard c++, and then push my output to gcc.

What then i need to do is to plug-in a preprocessor for file, which must be called when a condition on file is met (when this non-standard extensions are met).

How do i go about adding such a functionality? through code or command-line argument to gcc?

maress
  • 3,533
  • 1
  • 19
  • 37

2 Answers2

3

Don't try to do this through g++. Just set up your makefile so that it knows about your precondition(s) and shells out to your preprocessor before even calling g++ at all.

Mark B
  • 95,107
  • 10
  • 109
  • 188
0

You can pipe text into GCC, see Is it possible to get gcc to read from a pipe?. This might be a solution for your needs, depending on whether you already have a tool that will do your preprocessing and generate output on stdout.

Or alternatively as Nicklas suggested, write a makefile rule to convert files with your non-standard extension into .cpp files.

Community
  • 1
  • 1
Tom Quarendon
  • 5,625
  • 5
  • 23
  • 30