Questions about DLL

New to FreeBASIC? Post your questions here.
Post Reply
Nine
Posts: 4
Joined: Apr 09, 2020 18:58

Questions about DLL

Post by Nine »

1- How do I remove the suffix @xx in the dll when compiling in 32 bits ?

2- When compiling the dll in 64 bits, integer are consider 64 bits with pointer :

Code: Select all

#Include Once "windows.bi"

declare function Scan alias "Scan"(byval struct as integer pointer, byval color as integer, byval length as integer) as integer

function Scan(byval struct as integer pointer, byval iColor as integer, byval length as integer) as integer export
	MessageboxEx(0, str(*struct), "Test", MB_OK, 0)
	for i as integer = 0 to length - 1
		if struct[i] = iColor then
			function = i + 1
			exit function
		end if
	next
	function = 0
end function
Thanks for any help.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Questions about DLL

Post by MrSwiss »

I'm assuming you're on Windows.

1) don't use the U/Integer data-type to interface with C/C++ (WIN-API) use U/Long instead.
(U/Integer is always ptr-size, not fixed-size, which is expected)

2) 32-bit Color is always ULong (consists of 4 x UByte).

3) use Extern "windows-ms" in DLL-code (32-bit only), to get rid of @nn (name mangling).
Nine
Posts: 4
Joined: Apr 09, 2020 18:58

Re: Questions about DLL

Post by Nine »

@MrSwiss. Thank you for the prompt and precise answer. Works perfectly. :-)
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: Questions about DLL

Post by UEZ »

Hi Nine, welcome to the Freebasic community, :-)
Post Reply