LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++/C (https://www.linuxquestions.org/questions/programming-9/c-c-908131/)

kalleanka 10-14-2011 04:49 AM

C++/C
 
Hi,

I have a c++ program (main is c++) and i use a lot of c in it with "external c" in the headers. I have one .cpp file with a class and some external c functions like

class myclass : ....
...
...
};

#ifdef _cplusplus
extern "C" {
#endif

mycfuncs();
...
...

#ifdef _cplusplus
}
#endif


So now i need to call mycfuncs() from another c function in another c file.

The problem is including this header in c since it inludes a c++ class.

How and can I exclude the class declaration if used in c?

Thanks in advance.

kalleanka 10-14-2011 05:05 AM

ok I solved it like this(goes throw the compiler):

#ifdef _cplusplus

class myclass : ....
...
...
};


extern "C" {
#endif

mycfuncs();
...
...

#ifdef _cplusplus
}
#endif


All times are GMT -5. The time now is 12:13 PM.