Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-11

FPC macros

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tim Blume

Hi,

for several Pascal headers for C libraries it would be very nice, when macros defined in the interface section would be globally avaible.

E.g. in Assimp there are macros like this:

#define AI_MATKEY_NAME "?mat.name",0,0

Which I translated like this:

{$DEFINE AI_MATKEY_NAME:='?mat.name',0,0}

But since they are not avaible in other units, these translation have to be in an external *.inc file, which have to be included in every unit want to use these macros. This is quite disgusting imo.

Greetings
Tim Blume (End)

Reply by email

leledumbo
to Tim Blume
for several Pascal headers for C libraries it would be very nice, when

macros defined in the interface section would be globally avaible.

It won't, it will be nice for your only particular case (save typing). See point #2 of http://freepascal.org/faq.var#extensionselect

But since they are not avaible in other units, these translation have to be in an external *.inc file, which have to be included in every unit want to use these macros. This is quite disgusting imo.

IMO the use of macro itself, in your case, is already an abuse. If it's only to name '?mat.name', then a const is better. But I guess this is only to shorten writing multiple parameters, which is not a good reason since it compromises ease of reading (misguess the real number of parameters). FPC preprocessor is not as sophisticated as C/C++ and it's designed as such to disallow abuses. If you insist, please use external preprocessor instead.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/FPC-macros-tp5720549p5720550.html Sent from the Free Pascal - General mailing list .

Reply by email