Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12369 Discussions

Problem mixing C and C++ codes

Altera_Forum
Honored Contributor I
774 Views

Hi all, 

 

I am justing using NIOS IDE for one day. 

I can compile/link C sources in IDE. I can also compile C++ sources, but linker complained "undedfined main",  

since I compile the source with the 'main' function in a C++ way (because the main function needs to access C++ programs. 

 

Any suggestion how to mix C codes with C++ classes? 

 

Regards, 

 

Kwok Wong
0 Kudos
2 Replies
Altera_Forum
Honored Contributor I
65 Views

 

--- Quote Start ---  

originally posted by kwokwong@Jul 27 2004, 04:30 AM 

hi all, 

 

i am justing using nios ide for one day. 

i can compile/link c sources in ide. i can also compile c++ sources, but linker complained "undedfined main",  

since i compile the source with the 'main' function in a c++ way (because the main function needs to access c++ programs. 

 

any suggestion how to mix c codes with c++ classes? 

 

regards, 

 

kwok wong 

--- Quote End ---  

 

Problem solved: define C main function in C++ program 

 

extern "C" { 

int main() { 

// C++ codes 

}
Altera_Forum
Honored Contributor I
65 Views

FYI, you can also say: 

extern "C" int main() {    // C++ codes } 

Might be a little easier on the eyes.
Reply