Lazarus

Programming => General => Topic started by: fasdfasdfasdfasdfasdf on December 06, 2018, 04:01:27 pm

Title: Preprocessor
Post by: fasdfasdfasdfasdfasdf 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
Title: Re: Preprocessor
Post by: marcov 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.
Title: Re: Preprocessor
Post by: fasdfasdfasdfasdfasdf on December 06, 2018, 04:15:34 pm
Could I use something like namedpipes?
Title: Re: Preprocessor
Post by: marcov on December 06, 2018, 04:27:23 pm
Afaik no, there is no way, except storing the intermediate results.
Title: Re: Preprocessor
Post by: Edson 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.
Title: Re: Preprocessor
Post by: marcov 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.
Title: Re: Preprocessor
Post by: fasdfasdfasdfasdfasdf on December 07, 2018, 05:02:03 pm
AFAIK GDB has support for macros.
TinyPortal © 2005-2018