My app runs on both PC and Mac. It requires a dll or dylib, depending on target. I want to only have one source file that can be edited with Mac or PC XOJO. Although my build settings reflect the platform, I can’t seem to get the Declares correct. I “thought” that using TargetWin32 would help, but this fails (DxStart “does not exist”) when compiled on Mac and PC, regardless of build settings:
If TargetWindows Then
Declare Function DxStart Lib “pmbridge.dll” () As Integer
else
Declare Function DxStart Lib “/usr/local/lib/libPmbridge.dylib” () As Integer
end//target
If I do this, Mac is OK:
If TargetWindows Then
Declare Function DxStart Lib “pmbridge.dll” () As Integer
end//target
Declare Function DxStart Lib “/usr/local/lib/libPmbridge.dylib” () As Integer
If I do this, PC is OK
Declare Function DxStart Lib “pmbridge.dll” () As Integer
If TargetWindows Then
else
Declare Function DxStart Lib “/usr/local/lib/libPmbridge.dylib” () As Integer
end//target
What am I doing wrong? Or, How should this be done?
Thank You
#If TargetWindows Then
Declare Function DxStart Lib "pmbridge.dll" () As Integer
#else
Declare Function DxStart Lib "/usr/local/lib/libPmbridge.dylib" () As Integer
#endIf//target
BTW, tip to display code in a more legible manner like here : select it and click the code icon <[>] above the editor.
The # is the important bit, as Michel points out.
Using #if targetwindows (or TargetMacOs…) means that the code inside is actually included or excluded totally from the compile.
Using normal if TargetMacOs etc means both declares are compiled, in case the program takes one branch or the other.
The compat flags in the inspector, which is what I assume you meant, only let you select between desktop, web, console & iOS not between MacOS, Windows, Linux