extern functions

G

grahamo

Hi,

I have a set of routines that are declared thus (and implemented) in a
3rd party library;

extern "C"
{
void boo(type1 arg1, type2 arg2);
void hoo(type1 arg1, type2 arg2);
};



Now I want to wrap those functions in a wrapper class and use them
myself. Am I correct in assuming that all I need to do in the .cxx
implementation file that uses them is to declare them similarly;

i.e.

// my_source_file.cc

extern "C" void boo(type1 arg1, type2 arg2);
extern "C" void hoo(type1 arg1, type2 arg2);


and use them thus;

myClass:myMethod()
{
::boo(arg1, arg2);
}

and then to link against the third party library?


I can get the source to compile and link properly but at startup (on
Solaris), I am getting a "no mapping at fault address" -> core dump,
during initialisation of some completely unrelated static constructor
(i.e. a ctor in another distinct library).



Any help appreciated. I have a core file but it's solaris specific and
so doesn't really belong on this group.

thanks much and have a nice day


G.
 
V

Victor Bazarov

grahamo said:
I have a set of routines that are declared thus (and implemented) in a
3rd party library;

extern "C"
{
void boo(type1 arg1, type2 arg2);
void hoo(type1 arg1, type2 arg2);
};



Now I want to wrap those functions in a wrapper class and use them
myself. Am I correct in assuming that all I need to do in the .cxx
implementation file that uses them is to declare them similarly;

i.e.

// my_source_file.cc

extern "C" void boo(type1 arg1, type2 arg2);
extern "C" void hoo(type1 arg1, type2 arg2);

Why do you need to redeclare them if they are already in that library
and probably are declared in some header? Just include that header.
and use them thus;

myClass:myMethod()
{
::boo(arg1, arg2);
}

and then to link against the third party library?

Yes, but there should be no need to redeclare them.
I can get the source to compile and link properly but at startup (on
Solaris), I am getting a "no mapping at fault address" -> core dump,
during initialisation of some completely unrelated static constructor
(i.e. a ctor in another distinct library).

I don't think we here can help you with that...
Any help appreciated. I have a core file but it's solaris specific and
so doesn't really belong on this group.

Right.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,200
Messages
2,571,046
Members
47,646
Latest member
xayaci5906

Latest Threads

Top