* salkesh:
I have got a C++ code which has a namespace definition and some
functions in it -
namespace A {
int func1();
int func2();
}
Goodie.
now i want to access this functions from another function which has "C"
linkage...
how can i do this...?
currently i am doin it in this way but it is giving error -
What kind of error? Be specific. There are no mind-readers on planet
Earth, except the telepathic trolls from RadamrikambraMultibruFluxa 5,
but I think the last one is being hunted down as I write...
in a .h file i have defined a function as -
extern "C" int cfunc();
and the in the definition in the corresponding c++ file -
int cfunc()
{
int x = A::func1();
}
That's one way to do it, yes.
and i am compiling this with a g++ compiler to create a shared library
which is loaded in another C code ;-)
Be aware that C and C++ are two different languages, and have different
requirements for runtime library initialization. Possibly the C++
runtime library isn't being properly initialized (I haven't tried this,
so don't know). Try changing your _main_ program to C++, I think that
should maximize the chances of getting things to work; also see your
system and compiler specific documentation about shared library issues.
Btw., shared libraries are largely off-topic in this group.
That's because C++ doesn't actively support them.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?