Compiler Directives

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Gary.Maine
User
User
Posts: 34
Joined: Mon Oct 01, 2018 7:10 pm
Location: Winterport, Maine USA

Compiler Directives

Post by Gary.Maine »

When dealing with cross platform apps, It would be helpfull to have a complile driective like #Compile_Console
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: Compiler Directives

Post by helpy »

Just searched the PureBasic help:
Reserved Constants
The PureBasic compiler has several reserved constants which can be useful to the programmer:

Code: Select all

#PB_Compiler_ExecutableFormat : Determines executable format. It can be one of the following:
    #PB_Compiler_Executable : Regular executable
    #PB_Compiler_Console    : Console executable (have an effect only on Windows, other act like a regular executable)
    #PB_Compiler_DLL        : Shared DLL (dynlib on MacOS X and shared object on Linux)
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Gary.Maine
User
User
Posts: 34
Joined: Mon Oct 01, 2018 7:10 pm
Location: Winterport, Maine USA

Re: Compiler Directives

Post by Gary.Maine »

Thanks!
Gary.Maine
User
User
Posts: 34
Joined: Mon Oct 01, 2018 7:10 pm
Location: Winterport, Maine USA

Re: Compiler Directives

Post by Gary.Maine »

Nope, #PB_Compiler_Console = Syntax error Under Linux.

I will find a work around ..... but thanks for the responce.
User avatar
Shardik
Addict
Addict
Posts: 1991
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Compiler Directives

Post by Shardik »

Gary.Maine wrote:Nope, #PB_Compiler_Console = Syntax error Under Linux.
The following code doesn't display any syntax error on my Lubuntu 18.04 with LXDE regardless if it is compiled with Executable Format "Linux" or "Console":

Code: Select all

CompilerSelect #PB_Compiler_ExecutableFormat
  CompilerCase #PB_Compiler_Executable
    MessageRequester("Info", "Executable format: Executable")
  CompilerCase #PB_Compiler_Console
CompilerSelect #PB_Compiler_ExecutableFormat
  CompilerCase #PB_Compiler_Executable
    MessageRequester("Info", "Executable format: Executable")
  CompilerCase #PB_Compiler_Console
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
      OpenConsole("Executable format detection")
    CompilerEndIf

    PrintN("ExecutableFormat: Console")
    PrintN("Press <Enter> to continue!")
    Input()
  CompilerCase #PB_Compiler_DLL
    MessageRequester("Info", "Executable format: Library (.dll, .so or .dylib)")
CompilerEndSelect
  CompilerCase #PB_Compiler_DLL
    MessageRequester("Info", "Executable format: Library (.dll, .so or .dylib)")
CompilerEndSelect
But unfortunately the detection of console mode doesn't work in Linux and MacOS: you always obtain "Executable format: Executable" as documented in the help:
[color=#0040FF][u]Help for Compiler Directives[/u][/color] wrote:#PB_Compiler_Console: Console executable (have an effect only on Windows, other act like a regular executable)
Post Reply