Recent

Author Topic: Preprocessor  (Read 333 times)

r2r3

  • Newbie
  • Posts: 3
Preprocessor
« on: December 06, 2018, 04:01:27 pm »
I am trying to run the CPP preprocessor before compiling with FPC.
However it seems that FPC does not allow for using stdin for compilation.

cat somefile | gcc -E -fpreprocessed -xc - | fpc -O4
« Last Edit: December 06, 2018, 04:03:21 pm by r2r3 »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6617
Re: Preprocessor
« Reply #1 on: December 06, 2018, 04:12:09 pm »
Even if it would, FPC can need to load sourcecode (units) independently, so this would be of extremely limited use.

If you want to use the preprocesor, store the result of all files, and then compile.

r2r3

  • Newbie
  • Posts: 3
Re: Preprocessor
« Reply #2 on: December 06, 2018, 04:15:34 pm »
Could I use something like namedpipes?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6617
Re: Preprocessor
« Reply #3 on: December 06, 2018, 04:27:23 pm »
Afaik no, there is no way, except storing the intermediate results.

Edson

  • Hero Member
  • *****
  • Posts: 950
Re: Preprocessor
« Reply #4 on: December 06, 2018, 07:57:38 pm »
If using preprocessor this way, the line number for error messages will not fit the original sourcecode but the preprocessed source.
Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6617
Re: Preprocessor
« Reply #5 on: December 06, 2018, 08:03:19 pm »
Neither will it any other way, since when piping the compiler also only sees the preprocessed source. (in C this works by emitting #line directives, which of course won't work for pascal)

FPC simply does not integrate external preprocessing into the buildprocess. That is more something for languages without unitsystem.

Gnu Pascal might be a better way in such case.

r2r3

  • Newbie
  • Posts: 3
Re: Preprocessor
« Reply #6 on: December 07, 2018, 05:02:03 pm »
AFAIK GDB has support for macros.