[fpc-devel] Macro Processing

Jonas Maebe jonas.maebe at elis.ugent.be
Sat May 14 00:36:17 CEST 2011

On 14 May 2011, at 00:06, Joerg Schuelke wrote:

>  { definition contains the informations about a type }
>  tdeftyp = (abstractdef,
>    arraydef,recorddef,pointerdef,orddef,
>     typName : array[tdeftyp] of string[12] = (
>       'abstractdef','arraydef','recorddef','pointerdef','orddef',
> The first are spread over the source and not well solvable by the
> use of macros. An include will do it better.
> The second ones and you can believe me there are a planty more of such
> examples, are easy solveable by macros. Moreover they are not even
> marked to be kept in sync in the compiler sources.

1) the compiler automatically makes you keep them in sync, because adding/removing an element form the enumeration will cause a compilation error for the array if it's not updated
2) the array can actually be removed at some time in the future, because FPC can nowadays convert enumerations to their their name in string representation (via str(), write() and writestr()). There are still some bugs in this functionality in 2.4.x on some platforms though, so it can't be used yet in the compiler


More information about the fpc-devel mailing list