- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
is there a documentation how to migrate a running Nios II application (uses generated BSP with HAL drivers for DE2-70 Board SD card and Video interface) from C to C++ ? Best regards HolgerLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I solved the problem after a while. I renamed my source file containing the main function to Mainfile.cpp and did a refresh on the Eclipse Projekt. I used the BSP Editor in Eclipse to set Enable_c_plus_plus Then I generated the new BSP and rebuilt the whole Project. The next issue is an error from the generated Altera_UP_SD_Card_Avalon_Interface.h which reads as: # ifndef __ALTERA_UP_SD_CARD_AVALON_INTERFACE_H__ # define __ALTERA_UP_SD_CARD_AVALON_INTERFACE_H__ # include <stddef.h> # include <alt_types.h> # include <sys/alt_dev.h> # ifdef __cplusplus extern "C" { # endif /* __cplusplus */ ... # ifndef bool typedef enum e_bool { false = 0, true = 1 } bool; # endif This certainly can not compile with c++ (strange enough the extern "C" construct encourages a c++ compatibility which obviously has never been tested ). So I went through the generated source files and my source code calling them and replaced bool -> BOOL false -> FALSE true -> TRUE Rebuilding the BSP I got: Symbol NULL could not be resolved So I replaced NULL -> 0 With that the BSP did build without errors I defined the application project properties C/C++ General -> Paths and symbols -> Symbols __cplusplus so the extern "C" constructs with the generated files get visible. Next I got error from nread = write(console_io_fi,str,strlen(str)); which is defined in unistd.h _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte )); I replaced the# include <unistd.h> with: # include "sys/unistd.h" and then got to an error: Function '__builtin_stwio' could not be resolved This seemed to be complicated but finally I found a solution at: http://fpgaforum.blogspot.ch/2014/02/function-builtinstwio-could-not-be.html Which is really simple (but creepy) Go to the Window menue in main menu bar. Window->Preferences C/C++ -> Code Analysis Scroll down a bit on the right-hand column. Turned the option: Function cannot be resolved. from "error" to "warning" Important reminder, after applying the change of the setting, don’t forget to close the Eclipse IDE and reopen it. I noticed that without restarting the Eclipse IDE, the new setting is not effective. After restarting the Eclipse IDE, you will notice that the two semantic error messages above are no longer reported as error. This solution works but kills any expedient error if once you do not provide a necessary function. Regards Holger- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C and C++ maybe same in some basic syntax, but i found it more troublesome when convert from a C to C++ when involve more object oriented elements, i mean when in application layer . :)

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page