[fpc-pascal] Proper preprocessor?

Giuliano Colla giuliano.colla at fastwebnet.it
Wed Jun 20 13:36:38 CEST 2018


Il 20/06/2018 12:14, Michael Van Canneyt ha scritto:

> If you need a preprocessor, maybe you simply need to rethink your design.
>
> If you could explain your actual problem, maybe we can help solving it
> without resorting to preprocessing. 

In my experience a preprocessor comes handy mainly during the 
development of an application. E.g.: you need to evaluate if solution A 
is better than solution B, and each solution involves calling a 
different procedure with a different number of parameters, in dozens of 
points of your code.

This is an example from a C program:

> #define CON_TMAX #ifdef CON_TMAX #define AspettaRisposta(x,y,z) SMD 
> aspetta_risp(y,z) #else #define AspettaRisposta(x,y,z) SMD rqwait(x,z) 
> #endif 

A #define makes it possible to compare the two solutions with the same 
efficiency you'll get in the final version. A workaround, such as an 
extra procedure which does the same job, generates some extra code and 
may not tell you the full story.

It's not matter of rethinking the design, but of picking up the best design.

Just my 2 cents

Giuliano



More information about the fpc-pascal mailing list