Recent

Author Topic: Preprocessor  (Read 2083 times)

fasdfasdfasdfasdfasdf

  • New Member
  • *
  • Posts: 45
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

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
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.

fasdfasdfasdfasdfasdf

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

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
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: 1301
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 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
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.

fasdfasdfasdfasdfasdf

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

 

TinyPortal © 2005-2018