Page 1 of 1

error: invalid preprocessing directive

Posted: Mon Aug 22, 2022 3:26 pm
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?

Re: error: invalid preprocessing directive

Posted: Tue Aug 23, 2022 7:45 am
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

Re: error: invalid preprocessing directive

Posted: Tue Aug 23, 2022 8:04 am
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

Re: error: invalid preprocessing directive

Posted: Tue Aug 23, 2022 8:30 am
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.

Re: error: invalid preprocessing directive

Posted: Tue Aug 23, 2022 9:35 am
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)