B
Bill Nolan
Hi all,
I am having a problem with a bit a C++ code I am using and was hoping
for some pointers.
the code looks like this:
"libA.h"
.....
.....
typedef struct foo{
long (*funcA) ( proto-A ) ;
long (*funcB) ( proto-B ) ;
etc...
}foo;
extern foo *pfoo ;
"libA.cpp"
#include <libA.h>
....
int entry_func(){
return secodary_func();
}
LOCAL int secondary_func(){
baz = (*pfoo->funcA) ( vars ... );
.....
}
Compile and link libA.cpp as part of a library libA.a
then use it in libB
"libB.cpp"
#include <libA.h>
stuff using libA's entry_func()
Compile and link libB.cpp in to libB.a
use both libB and libA in hello_broken.cpp
"hello_broken.cpp"
// No includes for either libA or libB <---- I think this is broken ,
but it seems
to work
compile hello_broken
link using g++ -I<include paths> -L<paths> -lA -lB hello_broken.o -o
runme.exe
returns an error that "pfoo" is an undefined refrance, I agree with the
linker that I did not tell it where to find pfoo, but I lack the
understanding to fix it and was hopeing you could help. Including the
header "libA.h" does not fixt it, which was my first response.
This is all in code that I do not maintain, It is being used in a mixed
C and CPP program any help or pointers would be much apprecaited.
Additionaly If anyone has a sugjestion for a good book or website on
C++ for a C programer I would be in your debt.
--bill
I am having a problem with a bit a C++ code I am using and was hoping
for some pointers.
the code looks like this:
"libA.h"
.....
.....
typedef struct foo{
long (*funcA) ( proto-A ) ;
long (*funcB) ( proto-B ) ;
etc...
}foo;
extern foo *pfoo ;
"libA.cpp"
#include <libA.h>
....
int entry_func(){
return secodary_func();
}
LOCAL int secondary_func(){
baz = (*pfoo->funcA) ( vars ... );
.....
}
Compile and link libA.cpp as part of a library libA.a
then use it in libB
"libB.cpp"
#include <libA.h>
stuff using libA's entry_func()
Compile and link libB.cpp in to libB.a
use both libB and libA in hello_broken.cpp
"hello_broken.cpp"
// No includes for either libA or libB <---- I think this is broken ,
but it seems
to work
compile hello_broken
link using g++ -I<include paths> -L<paths> -lA -lB hello_broken.o -o
runme.exe
returns an error that "pfoo" is an undefined refrance, I agree with the
linker that I did not tell it where to find pfoo, but I lack the
understanding to fix it and was hopeing you could help. Including the
header "libA.h" does not fixt it, which was my first response.
This is all in code that I do not maintain, It is being used in a mixed
C and CPP program any help or pointers would be much apprecaited.
Additionaly If anyone has a sugjestion for a good book or website on
C++ for a C programer I would be in your debt.
--bill