Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
公告
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

c and cpp living together?

Altera_Forum
名誉分销商 II
1,216 次查看

Hello forum, 

 

I am working on a project using c and c++ code with eCos. I notice that eCos is written mainly in c++, but many other components in my system is written with c. This leads me to suspect that mixing c and c++ works OK if you know how. I have no trouble running an example project written in c, but when I start to incorporate cxx code files, things start to look bad. 

 

Before someone says, 'post to the eCos forum', my question is more fundamental - how do you go about mixing c and cxx code in the context of gcc and the NiosII IDE? 

 

Thanks in advance for any replies.
0 项奖励
3 回复数
Altera_Forum
名誉分销商 II
499 次查看

Hi, 

 

You can find much info from google.com.cn by using key words "mixing C and C++". 

 

when using C++ style function in *.c file, you'll need to do a "C"-style function in the CPP file in order to to link it. 

 

e.g. in CPP 

 

extern "C" void CreateForm (void) 

Form *frm = new Form(); 

 

 

then in main.c 

 

extern void CreateForm (void); 

 

int main () 

CreateForm () 

 

 

FYI. 

David
0 项奖励
Altera_Forum
名誉分销商 II
499 次查看

Hi  

Here i passed one link..from that you can get the idea and also solution for mixing c/c++ code in one file... 

 

 

http://developers.sun.com/prodtech/cc/articles/mixing.html (http://developers.sun.com/prodtech/cc/articles/mixing.html

 

Go through this. 

Definately you find the solution.. 

Let me know 

Best Regards, 

slsnios
0 项奖励
Altera_Forum
名誉分销商 II
499 次查看

They can life together well. 

Just make sure that all C++ is in a .cpp file. 

The compiler uses the file extention to change its mode
0 项奖励
回复