lua-users home
lua-l archive

Re: C API question

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Quoth Sam Roberts <vieuxtech@gmail.com>, on 2011年01月09日 09:49:13 -0800:
> > And this doesn't solve the problem for modules and other sorts of libraries.
> 
> Trying to guess what the "the problem" is, but for a module, you'd use
> a lightuserdata of a pointer to something in your modules C
> implementation, the module function, a static variable. C doesn't put
> multiple things at the same pointer address, so it will be unique.
Note that last I checked, ISO C proper doesn't guarantee much along
those lines for function pointers. (I think they're not even
guaranteed to be castable to void *.) So declaring a separate char or
int dummy variable is probably best in the general case; the extra few
bytes of memory are a small price to pay for a nice clean pointer
unless you're on a seriously memory-starved system.
> Sam
 ---> Drake Wilson

AltStyle によって変換されたページ (->オリジナル) /