- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am new to C++/ucos II.
Compiling a simple test C++ program gets the following error messages: error: 'alt_irq_register' was not declared in this scope error: invalid conversion from 'void*' to 'OS_STK*' error: initializing argument 3 of 'INT8U OSTaskCreateExt(void (*)(void*), void*, OS_STK*, INT8U, INT16U, OS_STK*, INT32U, void*, INT16U)' error: invalid conversion from 'void*' to 'OS_STK*' error: initializing argument 3 of 'INT8U OSTaskCreateExt(void (*)(void*), void*, OS_STK*, INT8U, INT16U, OS_STK*, INT32U, void*, INT16U)' Any help will be appreciated.Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Having the source to look at (or at least the correct segment) would be helpful.
First problem alt_irq_register not declared is you probably need the appropriate header file, the second problem look at what you have in the third argument position on your OSTaskCreateExt and either type-cast it to OS_STK* or define it properly.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, anakha
I forgot to mention that the same source is compiler error free using C. I got the error messages after renaming the program from .c to .cpp. Below is the relevant source codes: ----------- alt_irq_register(UART_IRQ,&context_uart,IsrUart ); OSTaskCreateExt(task1, NULL, (void *)&task1_stk[TASK_STACKSIZE-1], TASK1_PRIORITY, TASK1_PRIORITY, task1_stk, TASK_STACKSIZE, NULL, 0); OSTaskCreateExt(task2, NULL, (void *)&task2_stk[TASK_STACKSIZE-1], TASK2_PRIORITY, TASK2_PRIORITY, task2_stk, TASK_STACKSIZE, NULL, 0); ----------- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The GCC behaves different for c and c++ code. This is caused by the different file extentions. To make some library code like OS code run under c++ you have to declare it properly as "pure" c code. This is also required for some other hardware interface stuff.
for example: #ifdef __cplusplus extern "C" { #endif // c specific stuff #ifdef __cplusplus } #endif- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, Karsten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm working on a µC/OS II project using some C++. Compiling the example project "Hello MicroC/OS-II" works and simply changing the file extension from .c to .cpp or changing the target type in the makefile will still, in contrast to shacler, let project compile. But the Nios II build environment seems to have a problem to link the object files: make: *** [Cpp_Test.elf] Error 1 Cpp_Test C/C++ Problem and in the console output: [...] Cpp_Test_bsp/HAL/src/alt_main.c:154: undefined reference to `main' Any hints on how to fix this problem? According to the documentation C++ should work. Thanks in advance!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for pushing but the handover date is approaching :-S

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