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++

C++ in Nios II IDE?

Altera_Forum
Honored Contributor II
1,135 Views

I'd like to write some C++ code for my Nios II, but I haven't been able to compile a simple project or find a scrap of documentation on how to use C++ in the IDE. The fact that I can create a "C/c++ Project" gives me hope, but even a simple program like this fails to compile: 

 

#include <iostream> int main(int argc, char ** argv) {    cout << "Hello" << endl; } 

 

I&#39;m using N2IDE 1.0.0 build 316. It looks like the nios2-elf-gcc compiler ships with all the standard C++ header and library files, so I tried adding library and include directories in the project properties dialog, to no effect. 

 

What am I missing? http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/unsure.gif
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
406 Views

In the example you gave, you were missing both the namespace declaration and the return statement. Try this instead: 

 

# include <iostream> using namespace std; int main(int argc, char ** argv) {   cout << "Hello" << endl;   return 0; } 

 

If that still doesn&#39;t work for you, then check your file extensions. Fo a file to be compiled as C++ it needs to have one of the following extensions: .cxx, .cc, or .cpp.
0 Kudos
Altera_Forum
Honored Contributor II
406 Views

Er, right. "using namespace std" it is. No wonder the compiler couldn&#39;t find identifiers like "cout" and "endl". I&#39;ll get some sleep next time before I post. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/rolleyes.gif  

 

Thanks!
0 Kudos
Reply