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

Altera_Forum
Honored Contributor II
1,095 Views

Hi everyone, 

 

I was wondering if there comes an C++ example for the lightweight ip stack with NIOSII ? I only see c examples, but if i want to extend them with C++ it won't work because of the differences in C and C++. Ofcourse i can change the code to work with C++ but if there is a specific example i like too know, 

 

Thanks in advance, 

 

jmastron.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
384 Views

There should be no problem with calling the LWIP C functions from C++. The only thing you have to ensure is that function prototypes are declared to be external C functions. 

 

The easiest way to do this is to wrap the include for the LWIP files in an extern "C" decleration, e.g.: 

 

extern "C" {# include "lwip/sys.h"# include "lwip/netif.h"# include "lwip/sockets.h" 

}; 

 

Other than that, everything should work fine.
0 Kudos
Altera_Forum
Honored Contributor II
384 Views

Ok, I know that I should use extern "C". 

I only wants to have an working C++ example for the lwip module, because the given examples are in C, and it is not so easy to convert them to C++ (I tried, but didn't get it working). Adding "extern "C"" isn't enough. 

 

Thanks anyway, 

 

Michel.
0 Kudos
Reply