Forum Discussion
Altera_Forum
Honored Contributor
20 years agoClass and C++
Hi everyone, I'm brand new developer with NiosII and C++, and I'm experiencing some problems with NiosII IDE, expecially in building application in C++. I created a classe called "...
Altera_Forum
Honored Contributor
20 years ago --- Quote Start --- originally posted by g.sanzi@Mar 28 2006, 10:03 AM hi everyone,
i'm brand new developer with niosii and c++, and i'm experiencing some problems with niosii ide, expecially in building application in c++.
i created a classe called "thread". i wrote 2 files, an simple header file thread.h and a cpp file, thread.cpp.
during building, i receive this error message:
compiling thread.cpp...
../thread.cpp:10: error: new types may not be defined in a return type
../thread.cpp:10: error: return type specification for constructor invalid
../thread.cpp: in member function `void thread::begin()':
../thread.cpp:16: error: `timer_base' undeclared (first use this function)
../thread.cpp:16: error: (each undeclared identifier is reported only once for each function it appears in.)
../thread.cpp:16: error: expected primary-expression before ')' token
../thread.cpp: in member function `void thread::end()':
../thread.cpp:26: error: `timer_base' undeclared (first use this function)
make: *** [obj/thread.o] error 1
Code listed below: thread.h[/b] # ifndef _THREAD_H_# define _THREAD_H_ # define TIMEOUT# define TIME# include "altera_avalon_timer_regs.h" class thread { public: int state; int ticks; thread(); ~thread(); void begin(); void end(); int getState(); } # endif //_THREAD_H_
code listed below: thread.cpp # include <system.h> # include "thread.h"# include "altera_avalon_timer_regs.h" void thread::thread() {} void thread::~thread() {} void thread::begin(void) { // inizializzazione timer e partenza IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_BASE, TIME); IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_BASE, 0x00); IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_BASE, 0x07); state = 1; ticks = 0; } void thread::end(void) { // terminazione timer IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_BASE, 0x0b); state = 0; } int thread::getState(void) { return state; } So, I don't understand where are the problems: 1. What does it mean "new types may not be defined in a return type"? 2. Why TIMER_BASE is unknown, although is defined in <system.h> header file? Someone can help me? Thanks. G. <div align='right'><{post_snapback}> (index.php?act=findpost&pid=13853) --- Quote End --- [/b] --- Quote End --- i solved myself: it's only for a fucked ";" after class declaration!!!!!!!