2 Replies Latest reply: Sep 30, 2013 2:30 PM by BrianVandenberg RSS

    Is it possible to make the compiler driver use a third-party pre-processor?

    BrianVandenberg

      In other compiler suites I've used in the past it's been possible to force the compiler driver to use a different pre-processor if it was needed.  Does Sun Studio offer similar functionality?

       

      Ultimately what I'm after is finding a way to force the compiler to do pre-processing and compilation in separate processes.

       

      -Brian

        • 1. Re: Is it possible to make the compiler driver use a third-party pre-processor?
          Steve.Clamage-Oracle

          What compiler(s) are you using --C, C++, or Fortran?

          What version of Studio are you using?

          The exact answer might depend on the compiler and version.

           

          But before looking at replacements for the compiler's own preprocessor, do you really want to run your own preprocessing program? If so, the the recognition of source code and the output format need to be compatible with the compiler.

           

          If you just want to separate preprocessing from the rest of the compilation, you can use the -P or -E options to get the preprocessor output, then compile that output. To maintain correspondence with the original source code files and lines, you would use the -E option. C example:

          % cc -E hello.c > newhello.c

          % cc newhello.c

          % ./a.out

          Hello

           

          For C++, templates can introduce problems when you expect the compiler to find template definitions automatically, as is the case with the standard library. You will  probably need to add the option -template=no%extdef to be able to compile template code. C++ example:

          % CC -E -template=no%extdef hello.cc > newhello.cc

          % CC -template=no%extdef  newhello.cc

          % a.out

          Hello world.

           

          Refer to the C++ Users Guilde chapters on template compilation models for for details.

          • 2. Re: Is it possible to make the compiler driver use a third-party pre-processor?
            BrianVandenberg

            I'm trying to work around a problem I'm running into when building boost.  The no%extdef may be the workaround I need.

             

            However, to more directly respond: I figured (wrongly, it seems) there would be a built-in option that lets you specify the pre-processor to use.

             

            -Brian