delphi - How to overcome 255 character limit on conditional defines? -


conditional defines in delphi limited 255 characters. means if have more 255 characters of defines, ignored. e.g.

enter image description here

so set of conditional defines:

win32api;alarmserverengineversion27;imnotusingoldersimplethread;enablejclexceptiontracking;saveexceptionstodatabase;showexceptionform;snapin_needs_node_descriptor;virtual_trees_mouse_down_focus_last;usesqlserverlocking;snapinfactoryformclassisoptional;strict;siffcio;sqm 

the last 3 defines ignored.

what need way define conditional defines in project, while not being limited 255 characters.

i thought maybe moving conditional defines project source file, perhaps included through in include file:

program consotomanager;  {$r *.res} {$r '..\resource\wumpa.res' '..\resource\wumpa.rc'} {$define win32api} ... {$define sqm} {$define strict}  uses   fastmm4,   windows,   sysutils, 

unfortunately doesnt' work. reason doesn't work cannot substitute defines conditional defines; defines last until end of file.

so, how overcome 255 character limit on conditional defines in delphi?


the problem, of course, how have project level defines, while have shared source code files (shared files in own directories, outside of project folder).

you're there definitions in project file, remember delphi isn't c — compiler doesn't read each mentioned unit in sequence each time compiles anything, though files pasted textually, things defined in project file won't visible outside file.

however, delphi is c in supports directive named include does cause re-read mentioned file on every compilation. let's use that.

first, put definitions separate text file. let's call defines.inc.

{$define win32api} ... {$define sqm} {$define strict} 

then include file all source files need of definitions.

program consotomanager;  {$r *.res} {$r '..\resource\wumpa.res' '..\resource\wumpa.rc'} {$include defines.inc}  uses   fastmm4,   windows, 

now can clear list in project options , instead add whatever definitions need file. when change file, might need full build (rather simple compile) in order changes take effect.

also, consider whether need many compilation variables. maybe of them always defined, doesn't make sense check them @ compilation time. maybe of them redundant.


Comments