C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling a C library function from within C++

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Glenn C. Rhoads
Guest





PostPosted: Wed Oct 20, 2004 9:41 pm    Post subject: Calling a C library function from within C++ Reply with quote



I'm having a problem calling a C function from a publicly available
library file. To get the code to compile, I had to declare the
function as an external C function as follows.

extern "C" lib_function(....);

But when I run my C++ program, I get a segmentation fault in one
of the library functions (not the function I directly called but
one a few levels down in the calling hierarchy). According to
the user manual provided with the library, I'm passing in the
arguments correctly and I've allocated space for the arrays being
passed (each argument is either an integer or an array of integers),
hence I suspect the problem has something to do with the fact that
I'm calling a C function from within C++. (the authors claim that
the C code has no known bugs).

Any ideas on what the problem could be?

Note that I am using the gcc/g++ compiler on UNIX. In case you're
interested, the library package I'm using is called HMETIS and is
available at http://www-users.cs.umn.edu/~karypis/metis/

Also if you want to respond via email, then send your message to
rhoads <at> paul <dot> rutgers <dot> edu (the yahoo.com address
is bogus).

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Ron Natalie
Guest





PostPosted: Thu Oct 21, 2004 4:45 pm    Post subject: Re: Calling a C library function from within C++ Reply with quote



Glenn C. Rhoads wrote:
Quote:
I'm having a problem calling a C function from a publicly available
library file. To get the code to compile, I had to declare the
function as an external C function as follows.

extern "C" lib_function(....);

What is the declaration of the fuction in C?


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
GTO
Guest





PostPosted: Thu Oct 21, 2004 5:23 pm    Post subject: Re: Calling a C library function from within C++ Reply with quote



I assume that you know this

http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html

Gregor


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.