- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 1code listed below: thread.h # 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.
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- 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!!!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello,
I cannot define a class using Nios II IDE environment! the class is defined in basicOCR.h as follow: --- Quote Start --- class basicOCR{ public: float classify(IplImage* img,int showResult); basicOCR (); void test(); private: char file_path[255]; int train_samples; int classes; CvMat* trainData; CvMat* trainClasses; int size; static const int K=10; CvKNearest *knn; void getData(); void train(); }; --- Quote End --- Although "Support C++" is activated, errors occur: --- Quote Start --- ../basicOCR.h: At top level: ../basicOCR.h:25: error: syntax error before "basicOCR" ../basicOCR.h:25: error: syntax error before '{' token ../basicOCR.h:30: error: syntax error before ':' token --- Quote End --- any ideas ? thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is your .h file included from a .c file or a .cpp? I think it needs to be .cpp so that Eclipse compiles it in C++ mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually it did (basicOCR.cpp)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmmm I don't think that you need to rename the header files to .hpp to make the compiler stay in C++ mode.
The include statement isn't inside an extern "C" {} block by any chance?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
renaming the header files came out with nothing!
the basicOCR.cpp includes the header file as (#include "basicOCR.hpp"), but does this have to do with the header file itself? I'm sorry if I couldn't get your last reply!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Be sure the class declaration in the header file ends with a ;, like:
class abc
{
//.....
};
Bill
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