473,748 Members | 7,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ISO C++ forbids declaration of 'Rectangle' with no type

Hello,
I'm trying to compile a programme which compiles fine under Linux; I'm
trying it with MinGW G++ 3.4.2:
Component.h:

#ifndef COMPONENT_H_
#define COMPONENT_H_

#include "../basics/Rectangle.h"

class Component {
private:
Rectangle *bounds;
// Unique identifier
long id;

// more declarations

};

#endif
Rectangle.h (relative path is as included above):

#ifndef RECTANGLE_H_
#define RECTANGLE_H_

#include "Point.h"

class Rectangle
{
// some declarations
};

#endif
Point.h (same directory as Rectangle.h)

#ifndef POINT_H_
#define POINT_H_

class Point {
// some declarations
};

#endif
Now, in Windows, I always get the following compilation errors (where
line 25 in Component.h matches the line "Rectangle *bounds;" shown
above):

In file included from visdgetsbase.h: 13,
from main.cpp:14:
widgets/Component.h:25: error: ISO C++ forbids declaration of
`Rectangle' with n
o type
widgets/Component.h:25: error: expected `;' before '*' token
widgets/Component.h:41: error: ISO C++ forbids declaration of
`Rectangle' with n
o type
widgets/Component.h:41: error: expected `;' before '*' token
widgets/Component.h:43: error: variable or field `setBounds' declared
void
widgets/Component.h:43: error: expected `;' before '(' token

So, why isn't Rectangle recognized as a type?

I tried removing the relative path in #include, but that only results
in an additional error message saying that the file Rectangle.h wasn't
found at all. I also made sure I don't have any other file called
Rectangle.h on my entire hard disk, so quite obviously, with the
relative paths given in the #include directive, the correct file
should've been found, then why isn't the type Rectangle?

Thanks in advance,
Florian
Jan 24 '07 #1
7 9430
On Jan 24, 1:35 pm, "Florian Haag" <florianh...@ya hoo.dewrote:
Hello,
I'm trying to compile a programme which compiles fine under Linux; I'm
trying it with MinGW G++ 3.4.2:

Component.h:

#ifndef COMPONENT_H_
#define COMPONENT_H_

#include "../basics/Rectangle.h"

class Component {
private:
Rectangle *bounds;
// Unique identifier
long id;

// more declarations

};
#endif
In file included from visdgetsbase.h: 13,
from main.cpp:14:
widgets/Component.h:25: error: ISO C++ forbids declaration of
`Rectangle' with no type
Seems to me like the problem might be on line 25 in Component.h (or a
bit above), but the part from Component.h you pasted does not contain
the 25th line so I can't help you. Make sure that the last statement
above line 25 has a ; at the end.

--
Erik Wikström

Jan 24 '07 #2
Erik Wikström wrote:
Seems to me like the problem might be on line 25 in Component.h (or a
bit above), but the part from Component.h you pasted does not contain
the 25th line so I can't help you. Make sure that the last statement
above line 25 has a ; at the end.
Hi,
sorry if I explained this in a confusing way, actually, the line

Rectangle *bounds;

_is_ line 25, already shown in my code in the original posting (I
removed some comments when copying the code here).

Regards, thanks in advance,
Florian
Jan 24 '07 #3
Florian Haag wrote:
Erik Wikström wrote:
>Seems to me like the problem might be on line 25 in Component.h (or a
bit above), but the part from Component.h you pasted does not contain
the 25th line so I can't help you. Make sure that the last statement
above line 25 has a ; at the end.

Hi,
sorry if I explained this in a confusing way, actually, the line

Rectangle *bounds;

_is_ line 25, already shown in my code in the original posting (I
removed some comments when copying the code here).
Well, in removing that code, you probably removed the error. Post those
lines. (This is covered in the FAQ:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
Best

Kai-Uwe Bux
Jan 24 '07 #4
Kai-Uwe Bux wrote:
Well, in removing that code, you probably removed the error. Post
those lines. (This is covered in the FAQ:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
Sorry, this sent me to the right direction; there was a naming conflict
with a Rectangle-function from wingdi.h, which of course only occurred
in Windows.
I'm sorry for not having followed those rules, I still am not used that
in C++, there can be such an influence accross several files, unlike in
some other languages.

Regards,
Florian
Jan 24 '07 #5
Florian Haag wrote:
Kai-Uwe Bux wrote:
>Well, in removing that code, you probably removed the error. Post
those lines. (This is covered in the FAQ:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Sorry, this sent me to the right direction; there was a naming
conflict with a Rectangle-function from wingdi.h, which of course
only occurred in Windows.
I'm sorry for not having followed those rules, I still am not used
that in C++, there can be such an influence accross several files,
unlike in some other languages.
So C++ provides namespaces to isolate different components into their own
space.
Bo Persson
Jan 24 '07 #6


On Jan 24, 6:24 am, "Florian Haag" <florianh...@ya hoo.dewrote:
Kai-Uwe Bux wrote:
Well, in removing that code, you probably removed the error. Post
those lines. (This is covered in the FAQ:
http://www.parashift.com/c++-faq-lit...l#faq-5.8Sorry, this sent me to the right direction; there was a naming conflict
with a Rectangle-function from wingdi.h, which of course only occurred
in Windows.
I'm sorry for not having followed those rules, I still am not used that
in C++, there can be such an influence accross several files, unlike in
some other languages.
Other languages usually solve this "problem" with namespaces. It is
rare that a language allows the same symbol to be used to mean
different things.

Jan 24 '07 #7
Noah Roberts wrote:
I'm sorry for not having followed those rules, I still am not used
that in C++, there can be such an influence accross several files,
unlike in some other languages.

Other languages usually solve this "problem" with namespaces. It is
rare that a language allows the same symbol to be used to mean
different things.
Right, well - e.g. in Delphi, if you include another source file A, by
default, you just include the declarations from that very source file
A, not those of other source files B and C referenced by A.

Regards,
Florian
Jan 24 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2610
by: Henrik S. Hansen | last post by:
I'm new to C++, and cannot figure out why this won't compile: std::map<std::string, int> tst; tst = 1; int main() { /*...*/ } It gives me: error: ISO C++ forbids declaration of `tst' with no type
5
2747
by: j0mbolar | last post by:
operator = (const char *string) { if(m_string) { free(m_string); m_string = 0; } if(string) { m_string = strdup(string); } }
4
35029
by: Juhan Voolaid | last post by:
Hi I need help here. When i compile my program, i get this error: $ make g++ -c -Wall inf2_functions.cpp -o inf2_functions.o inf2_classes.h:6: error: ISO C++ forbids declaration of ‘vector’ with no type inf2_classes.h:6: error: expected ‘;’ before ‘<’ token make: *** Error 1
3
50488
by: gamehack | last post by:
Hi all, Here's the error which I'm getting when trying to compile some code: boxmanager.h:16: error: ISO C++ forbids declaration of 'vector' with no type boxmanager.h:16: error: expected ';' before '<' token boxmanager.h:17: error: ISO C++ forbids declaration of 'vector' with no type
1
7339
by: eric | last post by:
hello i'm trying to implement some functionality whereby an algorithm in a base template class relies on a function pointer supplied by a derived template class. the types are only specified by the client (caller) of the derived class. i got it working under visual studio 2003/2005 but gcc 4.1.0 compilation fails. here's the smallest subset of the code that shows the error:
6
6021
by: mkborregaard | last post by:
Hi, I am getting an error message from MinGW that I just cannot figure what causes. The error message is: "Line 16: ISO C++ forbids declaration of 'AreaMap' with no type" My code is: #ifndef RANGE_H_INCLUDED #define RANGE_H_INCLUDED #include "grid.h" //for type: presenceGrid #include <vector>
8
7875
by: aneuryzma | last post by:
Hello, I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using xCode. When I add #include "openCVApp.h" I got the following error:
6
14723
by: samsneelam | last post by:
Hi.. This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob.. I am having two files .. one is mpcplib.h it contains the follwing declerations.... #include <queue> #include <vector> #include <string> class database { queue<delayTP> delayThrouput;
10
4335
by: tvnaidu | last post by:
I am using Three pthread functions below, I got ISO error, then I declared int variable called val123, then I assigned, but still I am getting error, any idea?. also I included pthread.h. compiling in Linux with GCC. pthread_cond_signal(&(receiverConf->receive_q_cond)); pthread_cond_destroy(&(receiverConf->receive_q_cond)); pthread_mutex_destroy(&(receiverConf->receive_q_lock)); Main.cpp:545: ISO C++ forbids declaration of ` ...
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.