[nycbug-talk] Understanding sys/module.h , *module_t and *modeventhand_t
techneck at goldenpath.org
Thu Apr 10 00:55:20 EDT 2008
>>> Using cscope, I could find no definition for the "struct module"
>>> *module_t points to "struct module" (which is, apparently, undefined).
>>> If I have to guess, I'd say the module structure then becomes defined by
>>> we make module_t point to, so long as it's a structure.
>>> Later in hello.c
>>> modeventhand_t is set to point to our event handler function "load".
>>> *modeventhand_t expects for it's first argument (module_t), a pointer
>>> variable pointing to a structure type.
>>> but load expects for it's first argument (struct module *module), a
>>> dereferrenced pointer
>>> to a module structure that exists, but isn't defined?
>> You are wrong here - parameter declaration "struct module *module"
>> means module here is a pointer (otherwise it would just be
>> "struct module varname" - but people usually don't pass structures
>> by value in C :)
Woops! Yep, pretty obvious mistake in my reading.
It's confusing enough as it is. I ought not to be confusing myself on
top of it.
I guess you C pros do this pointer magic as naturally as breathing :)
More information about the talk