digitalmars.D.bugs - Linker error - function pointer
- Paul Runde (18/18) May 18 2004 This works per documentation:
- Andy Friesen (16/18) May 18 2004 It's a piece of global data just like any other. It's equivalent to the...
This works per documentation:
void function(int) dg;
void dothis(int x)
{
printf("%d\n", x);
}
void main(char[][] args)
{
dg = &dothis;
dg(5);
}
However, if I put the declaration of dg in another file (test2.d in this
case) I get:
Error 42: Symbol undefined _D5test22dgPFiZv
It works if I put test2.d in the build command line, but why is the
linker looking for a function pointer?
Thanks,
Paul
May 18 2004
Paul Runde wrote:It works if I put test2.d in the build command line, but why is the linker looking for a function pointer?It's a piece of global data just like any other. It's equivalent to the C++: test.cpp: #include "test2.h" void dothis(int x) { printf("%d\n", x); } int main(char** args) { dg = &dothis; dg(5); } test2.cpp: void (*dg)(int); test2.h: extern void (*dg)(int); The difference is that D doesn't need a separate .h file. -- andy
May 18 2004








Andy Friesen <andy ikagames.com>