Erros on macOS

Just starting out? Need help? Post your questions and find answers here.
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

Erros on macOS

Post by Wolfram »

I tried to compile one of my projects and I get an error message
Does anyone have an idea for a starting point ?
I get no information about line numbers and documents.

error: use of undeclared identifier 'mov'
mov [p.v_reg_b], rbx ; backup rbx
^
purebasic.c:4106:6: error: use of undeclared identifier 'p'
mov [p.v_reg_b], rbx ; backup rbx
^
purebasic.c:4106:18: error: use of undeclared identifier 'rbx'
...
2 warnings and 18 errors generated.
macOS Catalina 10.15.7
juergenkulow
Enthusiast
Enthusiast
Posts: 544
Joined: Wed Sep 25, 2019 10:18 am

Re: Erros on macOS

Post by juergenkulow »

Code: Select all

Procedure Test() 
  Protected reg_b.q
  ! mov [p.v_reg_b], rbx ;// backup rbx
EndProcedure

Test() 
; PureBasic 6.00 Beta 1 - C Backend (Linux - x64)
; Error: Assembler
; error: ‘mov’ undeclared (first use in this function)
;    mov    [p.v_reg_b], rbx ;// backup rbx
;    ^~~
; purebasic.c:65:3: note: each undeclared identifier is reported only once For each function it appears in
; purebasic.c:65:11: error: ‘p’ undeclared (first use in this function)
;    mov    [p.v_reg_b], rbx ;// backup rbx
;            ^
; purebasic.c:65:23: error: ‘rbx’ undeclared (first use in this function)
;    mov    [p.v_reg_b], rbx ;// backup rbx
;                        ^~~
; purebasic.c: In function ‘SYS_Quit’:
; purebasic.c:121:1: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
;  exit(PB_ExitCode);
;  ^~~~
; purebasic.c:121:1: warning: incompatible implicit declaration of built-in function ‘exit’
; purebasic.c:121:1: note: include ‘<stdlib.h>’ Or provide a declaration of ‘exit’
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Erros on macOS

Post by StarBootics »

Does your code contain Assembler instructions some where ? Because if you try to use the C backend with Assembler code you will end up with errors like that. If so you need to wrap it like that :

Code: Select all

    Protected Cos.f, Sin.f
    
    CompilerIf Defined(PB_Compiler_Backend, #PB_Constant) 
      
      CompilerIf #PB_Compiler_Backend = #PB_Backend_Asm
        
        !FLD dword [p.v_Theta]
        !FSINCOS
        !FSTP dword [p.v_Cos]
        !FSTP dword [p.v_Sin] 
        
      CompilerElseIf #PB_Compiler_Backend = #PB_Backend_C
        Cos.f = Cos(Theta)
        Sin.f = Sin(Theta) 
      CompilerEndIf 
      
    CompilerElse
      
      !FLD dword [p.v_Theta]
      !FSINCOS
      !FSTP dword [p.v_Cos]
      !FSTP dword [p.v_Sin] 
      
    CompilerEndIf 
Best regards
StarBootics
Last edited by StarBootics on Sat Nov 27, 2021 7:19 pm, edited 1 time in total.
The Stone Age did not end due to a shortage of stones !
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

Re: Erros on macOS

Post by Wolfram »

Yes, I forgot it, I have one function which is written in assembler.

Thanks.
macOS Catalina 10.15.7
WilliamL
Addict
Addict
Posts: 1214
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Erros on macOS

Post by WilliamL »

This works for me. So no assembler allowed in C right now...

Code: Select all

Procedure TryIt()
    Protected Cos.f, Sin.f , Theta
    CompilerIf Defined(PB_Compiler_Backend, #PB_Constant) 
        CompilerIf #PB_Compiler_Backend = #PB_Backend_Asm
            Debug "Assembler"
            !FLD dword [p.v_Theta]
            !FSINCOS
            !FSTP dword [p.v_Cos]
            !FSTP dword [p.v_Sin] 
        CompilerElseIf #PB_Compiler_Backend = #PB_Backend_C ;words ok when in C
            Debug "C backend"
            Cos.f = Cos(Theta)
            Sin.f = Sin(Theta) 
        CompilerEndIf 
    CompilerElse
        Debug"Something else?"
        !FLD dword [p.v_Theta]
        !FSINCOS
        !FSTP dword [p.v_Cos]
        !FSTP dword [p.v_Sin] 
    CompilerEndIf
EndProcedure

TryIt()
MacBook Pro-M1 (2021), Sonoma 14.3.1 (CLT 15.3), PB 6.10b7 M1
Post Reply