Compiler directive bug?

The following code:

[code] #if TargetMacOS

#if target64bit then MsgBox("64")

MsgBox "Mac OS"

#endif[/code]

works as expected on a Mac build, but gives an error when building for Windows 32bit and 64bit
“Syntax Error End Sub”
It seems the target64bit should be ignored when TargetMacOS is false…

I spent a few hours figuring out why a largish project (that used to compile) failed to compile yesterday… :confused:
Does this need a bug report? I’m assuming so, unless I’m somehow misusing the one-liner.

Maybe this:

[code]#if TargetMachO

#if Target64Bit
MsgBox(“64”)
#endif

MsgBox(“Mac OS”)

#endif[/code]

[quote=231000:@jim mckay]I spent a few hours figuring out why a largish project (that used to compile) failed to compile yesterday… :confused:
Does this need a bug report? I’m assuming so, unless I’m somehow misusing the one-liner.[/quote]

This feels like it should work. Please go ahead and file a bug report.

[quote=231006:@Eli Ott]Maybe this:

[/quote]
That does work, but the original code should work.

I’m just glad I was able to figure it out and get my project back on track! :slight_smile:

I think your code runs correctly, because:

TargetMacOS = OS X Carbon
TargetMachO = OS X Cocoa

But I’m not sure.

[quote=231146:@Eli Ott]TargetMacOS = OS X Carbon
TargetMachO = OS X Cocoa[/quote]

TargetMachO and TargetMacOS will both be true when targeting OS X.

The issue isn’t when compiling for MacOS. It’s when compiling for Windows the compiler chokes and can’t complete.

With a quick test, it seems that the compiler doesn’t like the form

#if target64bit then MsgBox("64")

For me, this returns an error of

As Eli suggested, change it to

[code]#if TargetMacOS

#if target64bit then
  MsgBox("64")
#endif

MsgBox "Mac OS"

#endif[/code]
and see if it works.

Right. I can change it (and did in my project) but the single line form should work and did work until r3