Need help from a Win32 programmer
Ben Collins <[email protected]> Mon, 29 Mar 2004 15:14:38 -0500
| Newsgroups | gmane.comp.lang.prothon.devel |
|---|---|
| Message-ID | <[email protected]> |
I'm not a Windows programmer, so I need someone to tell me if this style
of compiler/linker magic is possible with VC on win32.
What I want to do is make it so that modules can be built and either
linked as a module(dll in win32 speak) like we do now, or linked
directly into the prothon binary as a built-in, with no change in the
coding in the program, nor a direct knowledge by the prothon program
about these modules. This would simplify the code in the prothon
program and make it easier to custom build static prothon binaries with
certain specific modules built-in.
So I want to use a method I know works with gcc. I want to declare an
array of function pointers, but I want these pointers to be in a certain
code section, so I can reference them without knowing about them.
The way with gcc is something like this:
intptr_t function_table[] __attribute__((section(".myfuncsec")));
#define MY_FUNC_IN_TABLE(func) \
static void func(void); \
static intptr_t *func##_ptr \
__attribute__((section(".myfuncsec"))) = func; \
static void func(void)
MY_FUNC_IN_TABLE(initmod)
{
do stuff
}
intptr_t end_table __attribute__((section(".myfuncsec"))) = 0;
Then later I could increment over function_table and call all the
functions that are in the .myfuncsec (since function_table is the first
item in that section, I would skip function_table[0].
There's a bit more to it than that, but what I need to do is be able to
put items (just data items) in an arbitrary section like I've done
here using the __attribute__().
--
Debian - http://www.debian.org/
Linux 1394 - http://www.linux1394.org/
Subversion - http://subversion.tigris.org/
WatchGuard - http://www.watchguard.com/