error: invalid preprocessing directive

Mac OSX specific forum
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

error: invalid preprocessing directive

Post by collectordave »

Just moving some code from an earlier MAC to the new M1

Code compiles perfectly and runs on the earlier machine (PB 5.72LTS) but I get this error when using PB 6LTS for the MAC M1.
error: invalid preprocessing directive
#Slices = SizeOf(Integer); Use 8 slices on x64 and 4 on x86
^
purebasic.c:5899:3: error: use of undeclared identifier 'Structure'
Structure Nibbles : n.a[16] : EndStructure
^
purebasic.c:6055:37: error: expected ';' after expression
...
20 errors generated.
I have absolutely no idea so any help appreciated.

PS

Tried several times and a "clang error" came up?

Found restart compiler so in total desperation tried that then my stripped down programme compiled.

Does that help a little?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: error: invalid preprocessing directive

Post by collectordave »

Just trying a few more things and used this code

Code: Select all

Debug SizeOf(Integer)

If #PB_Compiler_Processor = #PB_Processor_x64
  
  Debug "X64"
  
Else
  
  Debug "X32"
  
EndIf
This returns 8 for the integer size indicating a 64bit processor?

but the compiler directive reports 32bit

I am on an iMac 24 , M1, 2012 running Big Sur 11.5.2

Is this a bug?

Changed the code to:

Code: Select all

Debug SizeOf(Integer)

CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
  
  Debug "X64"
  
CompilerElse
  
  Debug "X32"
  
CompilerEndIf
and still the same
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
Demivec
Addict
Addict
Posts: 4259
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: error: invalid preprocessing directive

Post by Demivec »

I'm not an expert or even a Mac owner but doesn't the Mac have a strictly 64-bit OS now and only do 64- bit compilations?

Second feature in the list of PureBasic features listed on purebasic.com:
FEATURES
  • Windows (x86 - x64), Linux (x86 - x64), OS X (x64, M1) and Raspberry (arm32, arm64) support
collectordave
Addict
Addict
Posts: 1310
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: error: invalid preprocessing directive

Post by collectordave »

Yes read that and the M1 chip does report as a 64bit when you use.

Code: Select all

   CompilerIf #PB_Compiler_Processor =  #PB_Processor_Arm64 ; not #PB_Processor_x64 
     
     Debug "Arm 64"
    
  CompilerElse
    
    Debug "Not ARM64"
 
  CompilerEndIf
This bit of code selects some assembler code but even selecting the correct processor size it still goes awry.

Is assembler on the arm64 different to the x64?

This s all in a module written by Wilbert to calculate a CRC32 checksum so maybe have to post the whole code for someone with a lot more knowledge than me to check.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: error: invalid preprocessing directive

Post by mk-soft »

I have macOS Intel and have looked at the constants for #PB_Compiler_Processor. With M1, #PB_Processor_Arm64 is supplied, which is also correct.

Code examples with assembler is written for Intel and must be rewritten, because the instruction set of the processor is different. Some of the code samples have already been rewritten for the C backend.

Code: Select all

Debug SizeOf(Integer)

CompilerIf #PB_Compiler_Processor = #PB_Processor_x64 Or #PB_Compiler_Processor = #PB_Processor_Arm64
  #Compile64 = #True
CompilerElse
  #Compile32 = #True
CompilerEndIf
I don't know exactly. But it should also run the PB version for Intel on M1 ? (Rosetta 2 Intel emulator)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply