documentation updated in wiki: EXTERN...END EXTERN* fbc: add extern "rtlib"
- add extern "rtlib" block, to make convenient, declaring functions within fb source code, but defined in fb's rtlib
- combines the behaviour of extern "c" with fbc default calling convention
- used in a namespace, has the effect of respecting the namespace within fb source code while also linking to regular C function
For example, rtlib has function fb_MemCopyClear() that wraps a crt memcpy() call followed by a memset() call.
Code: Select all
namespace FB
extern "rtlib"
declare sub MemCopyClear alias "fb_MemCopyClear"_
( _
byval dst as any ptr, _
byval dstlen as integer, _
byval src as const any ptr, _
byval srclen as integer _
)
end extern
end namespace
dim src as zstring * 10 = "FreeBASIC"
dim dst as zstring * 10 = "012345678"
print "before:"
print "src = " & src
print "dst = " & dst
print
'' copy first 4 bytes and clear the rest
FB.MemCopyClear( @dst, sizeof(dst), @src, 4 )
print "after:"
print "src = " & src
print "dst = " & dst
print
Code: Select all
before:
src = FreeBASIC
dst = 012345678
after:
src = FreeBASIC
dst = Free
Updating ASM documentation only insofar as default calling conventions are concerned.