Can not use a structure in an Import

All bugs related to new C backend
infratec
Always Here
Always Here
Posts: 7676
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Can not use a structure in an Import

Post by infratec »

I had this 'bug' in macOS:
viewtopic.php?t=87191

Now I stumpled across the same error when I use the C backend (x86) in windows:
error: unkonw type_name 's_pjsip_cfg_t'
136 | extern s_pjsip_cfg_t v_pjsip_sip_cfg_var asm("_pjsip_sip_cfg_var");
purebasic.c in function 'f_startsipstack':
purebasic.c46167:20: error: request for member 'f_disable_tcp_swi
More is not visible in the Assembler error message requester.
Fred
Administrator
Administrator
Posts: 18372
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Can not use a structure in an Import

Post by Fred »

Did you try with 6.30b3 ? I tried here with x86 and x64 on Windows and it seems to work

Code: Select all

Macro pj_bool_t : i : EndMacro

Structure pjsip_cfg_t Align #PB_Structure_AlignC
  allow_port_in_fromto_hdr.pj_bool_t
  accept_replace_in_early_state.pj_bool_t
  allow_tx_hash_in_uri.pj_bool_t
  disable_rport.pj_bool_t
  disable_tcp_switch.pj_bool_t
  disable_tls_switch.pj_bool_t
  follow_early_media_fork.pj_bool_t
  req_has_via_alias.pj_bool_t
  resolve_hostname_to_get_interface.pj_bool_t
  disable_secure_dlg_check.pj_bool_t
  use_compact_form.pj_bool_t
  accept_multiple_sdp_answers.pj_bool_t
  keep_inv_after_tsx_timeout.pj_bool_t
EndStructure

ImportC ""
    pjsip_sip_cfg_var.pjsip_cfg_t
  EndImport
  
  a = pjsip_sip_cfg_var
infratec
Always Here
Always Here
Posts: 7676
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can not use a structure in an Import

Post by infratec »

I just tried 6.30b3 x86 C backend,

but I can not compile the project because:
Declare does not fit the real procedure

Code: Select all


Structure Object
    Server_ID.i
    
    Network_Thread_ID.i
EndStructure

Prototype.i Prototype_Event_Callback(*Object, *Client, Event.i, *Custom_Structure=#Null)

Declare.i Event_Callback(*Object.Object, *Callback.Prototype_Event_Callback)

Code: Select all

Procedure.i Event_Callback(*Object.Object, *Callback.Prototype_Event_Callback)
Declare and Procedure are identical :shock:

In 6.21 it works without this problem.
Last edited by infratec on Fri Oct 10, 2025 1:51 pm, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18372
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Can not use a structure in an Import

Post by Fred »

Yes, I corrected this issue for the next beta. viewtopic.php?t=87674
infratec
Always Here
Always Here
Posts: 7676
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can not use a structure in an Import

Post by infratec »

So I have to wait for the next beta to test this.
User avatar
idle
Always Here
Always Here
Posts: 6058
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Can not use a structure in an Import

Post by idle »

infratec wrote: Fri Oct 10, 2025 1:52 pm So I have to wait for the next beta to test this.
drop the pointer or move procedure to where you don't need to declare it and leave the pointer

Code: Select all

Declare.i Event_Callback(*Object.Object, Callback.Prototype_Event_Callback)
Procedure.i Event_Callback(*Object.Object, Callback.Prototype_Event_Callback)
When I came across it, I suffered a little hair loss from being a dyslexic :lol:
infratec
Always Here
Always Here
Posts: 7676
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can not use a structure in an Import

Post by infratec »

I still can not compile the code with the C compiler. (PB 6.30 beta 4 x86 windows)

Now I get a PureBasic - Assembler error window with:

error: exected expression before ',' token 69864 | .cSize equ 2

purebasic.c .69884:26 error: unknown type name 'get'
69884 | movzx eax, byte [edx] ; get type

purebasic.c69885:1 error: expected '=', ',',';
User_Russian
Addict
Addict
Posts: 1600
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Can not use a structure in an Import

Post by User_Russian »

Maybe there is Inline assembler code?
infratec
Always Here
Always Here
Posts: 7676
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can not use a structure in an Import

Post by infratec »

User_Russian wrote: Wed Oct 29, 2025 10:31 am Maybe there is Inline assembler code?
No.
There is no inline assmbler line in th whole project.
User avatar
idle
Always Here
Always Here
Posts: 6058
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Can not use a structure in an Import

Post by idle »

Maybe it's from the LTO stage, its not Intel format.
User_Russian
Addict
Addict
Posts: 1600
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Can not use a structure in an Import

Post by User_Russian »

idle wrote: Wed Oct 29, 2025 7:55 pmMaybe it's from the LTO stage
Does PB use LTO (Link Time Optimization)?
But if so, it would be a linker error, not a compiler error.
User avatar
idle
Always Here
Always Here
Posts: 6058
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Can not use a structure in an Import

Post by idle »

User_Russian wrote: Wed Oct 29, 2025 8:05 pm
idle wrote: Wed Oct 29, 2025 7:55 pmMaybe it's from the LTO stage
Does PB use LTO (Link Time Optimization)?
But if so, it would be a linker error, not a compiler error.
I think it does use LTO now otherwise I don't see the point of changing from polink
if its not from that then maybe its from the Assembler stage why would the message be in att format.
it's like its compiled the c and then its dumping the disassembly.
Fred
Administrator
Administrator
Posts: 18372
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Can not use a structure in an Import

Post by Fred »

infratec wrote: Wed Oct 29, 2025 8:26 am I still can not compile the code with the C compiler. (PB 6.30 beta 4 x86 windows)

Now I get a PureBasic - Assembler error window with:

error: exected expression before ',' token 69864 | .cSize equ 2

purebasic.c .69884:26 error: unknown type name 'get'
69884 | movzx eax, byte [edx] ; get type

purebasic.c69885:1 error: expected '=', ',',';
Seems like you have inline assembly code in your project, did you check that ? If not, please send me the part of the generated output which show that (you can compile with /COMMENTED flag from the commandline using pbcompilerc.exe
Post Reply