On 15/09/2006, at 1:41 PM, Adelle Hartley wrote:
Andre Pang wrote:
Well, you don't have to typecheck plugins. If you don't,
though, your program will simply segfault :). If you don't
typecheck, you simply have a random pointer you know nothing
about, and are expecting it to be (1) proper code, and (2)
accept and return exactly the correct types for its
parameters and return value. (Note that is exactly what you
do in C when you get at a plugin's function via dlsym
() and cast it from a void* to whatever function type you
think it's meant to be...).
I will have to concede my ignorance on the OS/Linux way of doing
plugins,
but a quick google of dlsym has given me many hours of reading
material to consider :-o I guess I am kind of used to Windows/COM
holding my hand for this stuff.
Windows isn't much different: replace dlopen() with LoadLibrary(),
and replace dlsym with GetProcAddress(). Either way, you have some
sort of void* pointer (i.e. something that you don't know the type
of), which you must cast to a function pointer to do anything useful
with. A cast is C's way of telling the type system "I don't care
what the compiler thinks, just do as I say even though I might be
totally wrong", so you're not type checking whether the void* really
is a function pointer at all.
--
% Andre Pang : trust.in.love.to.save <http://www.algorithm.com.au/>
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders