Page 1 of 1

Can not use a structure in an Import

Posted: Fri Oct 10, 2025 1:04 pm
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.

Re: Can not use a structure in an Import

Posted: Fri Oct 10, 2025 1:26 pm
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

Re: Can not use a structure in an Import

Posted: Fri Oct 10, 2025 1:44 pm
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.

Re: Can not use a structure in an Import

Posted: Fri Oct 10, 2025 1:51 pm
by Fred
Yes, I corrected this issue for the next beta. viewtopic.php?t=87674

Re: Can not use a structure in an Import

Posted: Fri Oct 10, 2025 1:52 pm
by infratec
So I have to wait for the next beta to test this.

Re: Can not use a structure in an Import

Posted: Tue Oct 14, 2025 8:03 am
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:

Re: Can not use a structure in an Import

Posted: Wed Oct 29, 2025 8:26 am
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 '=', ',',';

Re: Can not use a structure in an Import

Posted: Wed Oct 29, 2025 10:31 am
by User_Russian
Maybe there is Inline assembler code?

Re: Can not use a structure in an Import

Posted: Wed Oct 29, 2025 11:11 am
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.

Re: Can not use a structure in an Import

Posted: Wed Oct 29, 2025 7:55 pm
by idle
Maybe it's from the LTO stage, its not Intel format.

Re: Can not use a structure in an Import

Posted: Wed Oct 29, 2025 8:05 pm
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.

Re: Can not use a structure in an Import

Posted: Thu Oct 30, 2025 1:05 am
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.

Re: Can not use a structure in an Import

Posted: Wed Nov 12, 2025 11:16 am
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