Just starting out? Need help? Post your questions and find answers here.
devox
User
Posts: 32 Joined: Thu Apr 01, 2021 7:25 pm
Post
by devox » Fri Apr 02, 2021 8:58 am
Hi,
I'm writing a plugin which is a DLL and the DLL exports some global variables. Here is the C version.
Code: Select all
// This from header file used by plugin.
#define EXTERN_C
#define DSP_EXPORT EXTERN_C __declspec(dllexport)
typedef char const* string;
Code: Select all
// This is from the c file and has what is exported in the DLL.
DSP_EXPORT string const name="Script Name";
DSP_EXPORT string description="Script Description";
I'm trying to do the equivalent of above in PB?
devox
User
Posts: 32 Joined: Thu Apr 01, 2021 7:25 pm
Post
by devox » Sat Apr 03, 2021 12:50 pm
After much playing around I'm managing to figure it out somewhat with this code.
Code: Select all
ImportC "/EXPORT:name" : EndImport
ImportC "/EXPORT:description" : EndImport
! public v_name as 'name'
Global name.s = "Purebasic"
! public v_description as 'description'
Global description.s = "Purebasic"
ProcedureDLL AttachProcess(Instance)
EndProcedure
ProcedureDLL DetachProcess(Instance)
EndProcedure
It seems the strings in purebasic are unicode is it possible to specify it as Ascii?
fryquez
Enthusiast
Posts: 367 Joined: Mon Dec 21, 2015 8:12 pm
Post
by fryquez » Sat Apr 03, 2021 3:51 pm
As long as PureBasic uses fasm:
Code: Select all
ImportC "/EXPORT:name" : EndImport
ImportC "/EXPORT:description" : EndImport
ProcedureDLL AttachProcess(Instance)
ProcedureReturn 1
!public _ASCCI_String1 as 'name'
!public _ASCCI_String2 as 'description'
!Align 4
!_ASCCI_String1:
!db "Hello", 0
!Align 4
!_ASCCI_String2:
!db "World", 0
EndProcedure