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 

Making C++ classes available for C

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Michael Rasmussen
Guest





PostPosted: Mon Jan 30, 2006 9:00 am    Post subject: Making C++ classes available for C Reply with quote



Hi all,

How do you make modules written i C++ available for C?

Until now I have done it this way:

foo.h
class foo {
public:
int bar();
}

foo.cc
int foo::bar()
{
return 1;
}

foo_c.h
int foo_c();

foo_c.cc
#include "foo.h"

foo f;

int foo_c()
{
return f.bar();
}

main.c
#include "foo_c.h"

int main()
{
printf("%d\n", foo_c());
return 0;
}

Any other suggestions?

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917
Back to top
Bob Hairgrove
Guest





PostPosted: Mon Jan 30, 2006 10:00 am    Post subject: Re: Making C++ classes available for C Reply with quote



On Mon, 30 Jan 2006 09:52:34 +0100, Michael Rasmussen <mir (AT) miras (DOT) org>
wrote:

Quote:
How do you make modules written i C++ available for C?

Read it in the FAQ:
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html

--
Bob Hairgrove
NoSpamPlease (AT) Home (DOT) com
Back to top
Michael Rasmussen
Guest





PostPosted: Mon Jan 30, 2006 11:00 am    Post subject: Re: Making C++ classes available for C Reply with quote



On Mon, 30 Jan 2006 10:49:31 +0100, Bob Hairgrove wrote:

Quote:

Read it in the FAQ:
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html
Thank you for the link. It is very usefull to me:-)

--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) 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.