#PB_Compiler_Target

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Joubarbe
Enthusiast
Enthusiast
Posts: 555
Joined: Wed Sep 18, 2013 11:54 am
Location: France

#PB_Compiler_Target

Post by Joubarbe »

Code: Select all

CompilerIf #PB_Compiler_Target = "Dev"
  Debug "Development code."
CompilerElse
  Debug "Production code."
CompilerEndIf
I know you can add it through custom constants, but I think it would be handy to have it pre-built.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: #PB_Compiler_Target

Post by BarryG »

This can already be done by using the built-in constant of #PB_Editor_CreateExecutable (with #PB_Editor_CreateExecutable also ticked in the Compiler Options for the app). So your code can do one thing if run from the IDE, and another thing if run from a compiled exe:

Code: Select all

Global appname$=ProgramFilename() ; Assume the user is running your app from a compiled executable (production code).
CompilerIf #PB_Editor_CreateExecutable=0 ; But if not, and is running from the IDE, use a hard-coded path (development code).
  appname$="C:\Hard\Coded\Path\To\Development.exe"
CompilerEndIf
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: #PB_Compiler_Target

Post by ChrisR »

Good to know for #PB_Editor_CreateExecutable, thanks :)
I was doing it, like Joubarbe, with a custom constant.
Post Reply