Forum Discussion
Altera_Forum
Honored Contributor
21 years agoC++ example
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.2 Replies
- Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
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.