I need to import a global variable from an external statically linked library.
In windows and linux this works without problems. In macOS it fails with a compiler error.
Example:
Code: Select all
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 #LibPJProjectFile
pjsip_sip_cfg_var.pjsip_cfg_t
EndImport
error: unknown type name 's_pjsip_cfg_t'
100 | extern s_pjsip_cfg_t v_pjsip_sip_cfg_var asm("_pjsip_sip_cfg_var");
| ^
1 error generated.
Ugly bugfix for macOS:
Code: Select all
ImportC #LibPJProjectFile
; BugFix für macOS -> kann keine lokale Struktur hinter exportierter Variable
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
pjsip_sip_cfg_var
CompilerElse
pjsip_sip_cfg_var.pjsip_cfg_t
CompilerEndIf
EndImport
; BugFix für macOS -> kann keine lokale Struktur hinter exportierter Variable
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Global *pjsip_sip_cfg_var.pjsip_cfg_t
*pjsip_sip_cfg_var = @pjsip_sip_cfg_var
CompilerEndIf
So I also need a CompilerIf in the code where the variable is used. (But I hope this will be solved in future

I can not provide a code which reproduce the error. Sorry.