Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Class design in Nios II with uC/OS

Hi i am a newbie on the NIOS II themes and i need to create a object oriented program on a NiosII system with uC/OS. I have NIOS II ide V9.0SP2 with a Nios II development kit.

In order to make my first test i use the hello world example without OS and the class was designed using the New C++ class wizard of the Nios II ide, here the code:

//hello_world.c
16     # include "miclase.cpp"
17     # include <stdio.h>
18      
19          int main()
20      {
21         miclase clase;
22         clase.miclase();
23         printf("Hello from Nios II!\n");
24
25         return 0;
26       }
//miclase.cpp
2        # include "miclase.h"
3         miclase::miclase(){}
4     
5         miclase::~miclase(){}
//miclase.h
2       # ifndef MICLASE_H_
3       # define MICLASE_H_
4        class miclase
5         {
6           public:
7	     miclase();
8	     virtual ~miclase(); 
9          };
10      # endif /*MICLASE_H_*/

when I build all the compiler throw this errors:

error: `clase' undeclared (first use in this function) hello_world.c line 22

error: `miclase' undeclared (first use in this function) hello_world.c line 21

error: syntax error before ':' token hello_world_1 miclase.cpp line 3

error: syntax error before '{' token hello_world_1 miclase.h line 5

error: syntax error before "clase" hello_world_1 hello_world.c line 21

error: syntax error before "miclase" hello_world_1 miclase.h line 4

:confused:

I dont know what to do because when I use similar code on the Hello world with uC/OS and the class declaration, the compiler throw the same errors. Later I check the check box

Support C++ on the system Library Properties and the erros continue.

So my final question is: How can i implement a full class design (with inheritance, template classes and so) on the Nios II development kit working with uc/OS II.

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It works, thank you :). I should make another changes to the code but basically you suggestion help me to find the solution.

    Thank you again.Karsten
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I forgot one thing because i was yesterday in a hurry.

    Make sure in your system lib that

    support c++

    is activated.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I have the same problem but I'm using Quartus 9.1SP2 and Nios IDe Sp2

    I renamed the file from .c to .cpp, the class error was gone but now I have a lot of new erros. When I return to .c file, the erros disapear.

    The "Support C++" option is marked and I don't change anything in the code, just include a class (.cpp and .h files)

    My code error is:

    Compiling hello_ucosii.cpp...

    ../hello_ucosii.cpp: In function `int main()':

    ../hello_ucosii.cpp:44: error: invalid conversion from `void*' to `OS_STK*'

    ../hello_ucosii.cpp:44: error: initializing argument 3 of `INT8U OSTaskCreateExt(void (*)(void*), void*, OS_STK*, INT8U, INT16U, OS_STK*, INT32U, void*, INT16U)'

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you must add to simple socket server.cpp the follow:

    extern "C" {# include <stdio.h># include <string.h>

    ...# include "ipport.h"# include "tcpport.h"

    }

    Anyway you can find a SSS code ready for c++, use it to begin any project. Search in google the file Sss_cpp.zip