Compiling Mac or PC

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

TargetWindows does not exists ?
docs: “There is currently no text in this page.”
developer.xojo: “The page cannot be found”

Also, don’t you miss the # in frint of the If ? (#If)

Conditional compilation :

#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.

Using with google.com:

site:developer.xojo.com TargetWindows

I get: Compiler Constants (@ developer.xojo.com).

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.

Slapping forehead…

Appreciate the how to post code and additional explanation of the difference betwixt #if and normal if.

Thank you all so much!

You can add the declare to a module and mark it for the correct platform, as well.

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

Sorry, I remembered that incorrectly. Thanks for correcting that misinformation.