Hi all!
How to use this class in a Static Library with multiple modules?
Here I am creating 2 modules:
1.bas:#Include "header.bi"
sub one(s as CWSTR)
? s
End Sub
2.bas:#Include "header.bi"
sub two(s as CWSTR)
? s
End Sub
And also the header file
header.bi #Include Once "AFX/CWSTR.INC"
declare sub one(s as CWSTR)
declare sub two(s as CWSTR)
I compile to a static library:
fbc -lib 1.bas 2.bas
Next, I run the example:
#Include "header.bi"
#inclib "1"
one("one")
two("two")
sleep
And I get errors:
./lib1.a(1.o):fake:(.text+0x0): multiple definition of `AFX::CBSTR_ISBSTR(void*)@4'
G:\test\FBTEMP.o:fake:(.text+0x0): first defined here
./lib1.a(2.o):fake:(.text+0x0): multiple definition of `AFX::CBSTR_ISBSTR(void*)@4'
G:\test\FBTEMP.o:fake:(.text+0x0): first defined here
As I understand it, a class is assigned to each module (including the executable), and the compiler does not like duplicate definition. I've already broken my whole head

-----------------------------
If I take create the same files, but simplified:
1.bas:#Include "header.bi"
sub one(s as CWSTR)
? "One"
s.ws = "One String"
End Sub
2.bas:#Include "header.bi"
sub two(s as CWSTR)
? "Two"
s.ws = "Two String"
End Sub
header.bi:Type CWSTR extends WSTRING
ws as wstring*40
End Type
declare sub one(s as CWSTR)
declare sub two(s as CWSTR)
example:#Include "header.bi"
#inclib "1"
dim as CWSTR sz
one(sz)
? Sz.ws
two(sz)
? Sz.ws
sleep
Everything works here.