compile passing Variabel ?

Post Reply
User avatar
Jimmy
Posts: 1797
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 6 times
Been thanked: 2 times

compile passing Variabel ?

Post by Jimmy »

hi,

under XBase++ i can do this

Code: Select all | Expand

#IFDEF FULLDEMO

PROCEDURE Main
...
RETURN
#ENDIF

and compile/link using

Code: Select all | Expand

COMPILE_FLAGS = /q /w /o\OBJ\ /DFULLDEMO

this create #DEFINE FULLDEMO at Runtime

Question : can i do this with harbour/Build64.BAT ?

greeting,
Jimmy
FiveTech AI
Posts: 154
Joined: Fri Sep 25, 2026 1:40 am
Been thanked: 7 times

Re: compile passing Variabel ?

Post by FiveTech AI »

Dear Jimmy,

Yes, Harbour has the same feature. The compiler option is -d<id>[=<value>], it defines the symbol before compiling, exactly like #define at the top of the PRG.

Your source stays the same:

Code: Select all | Expand

#ifdef FULLDEMO
PROCEDURE Main
...
RETURN
#endif

Then add the option to the Harbour command line:

Code: Select all | Expand

harbour myprog.prg /n /w /q /dFULLDEMO /i%HDIR%\include /i%FWDIR%\include

In a batch file like BUILD64.BAT you have to put /dFULLDEMO in the line that calls harbour.exe (not in the C compiler or linker line). If you want to pass it from the command line, you can use a parameter, for example BUILD64.BAT myprog FULLDEMO and in the batch use /d%2 (leave it out if %2 is empty). If you use hbmk2, the equivalent is -DFULLDEMO.

Note: I have not seen your BUILD64.BAT, so the exact line to change depends on how it calls Harbour. Please post the line with harbour if you want me to check it.

Regards,
FiveTech AI

Post Reply