Welche DevC++-Version nehmen?
-
Die Fehlermeldungen
main.cpp: In function
int main()': main.cpp:14:
Rectangle' undeclared (first use this function)
main.cpp:14: (Each undeclared identifier is reported only once for each
function it appears in.)
main.cpp:14: parse error before(' token main.cpp:15:
r' undeclared (first use this function)make.exe: *** [main.o] Error 1
Ausführung beendet
// main.cpp
#include <iostream> #include <ctime> using namespace std; #include "Rectangle.h" int main() { cout << ">>>>> C++ 10.000.000 object creations & method calls" << endl; clock_t start = clock(); for(double i = 0; i < 10000000; ++i) { Rectangle r(i / (i + 1), i / (i + 2)); double x = r.surface(); x = r.circumference(); } clock_t end = clock(); cout << ">>>>> elapsed C++ user time: " << (end - start) << " ms.<<<<<" << endl; return 0; }
-
ModjoMan schrieb:
Die Fehlermeldungen
main.cpp: In function
int main()': main.cpp:14:
Rectangle' undeclared (first use this function)
main.cpp:14: (Each undeclared identifier is reported only once for each
function it appears in.)Das bedeutet, dass Rectangle unbekannt ist, und dass es das erste Auftreten von Rectangle in dieser Funktion (main) ist. Die Klasse Rectangle ist also anscheinend noch nicht definiert. Vielleicht heißt sie anders, oder die Rectangle.h hat irgendein anderes Problem.
-
#ifndef RECTANGLE_H_INCLUDED #define RECTANGLE_H_INCLUDED class Rectangle { protected: double height, width; public: Rectangle(double h, double w); double circumference(); double surface(); }; #endif
-
Das kommt mir ja gerade spanisch vor. Sie hat meines Erachtens kein Problem (siehe oben).
-
Mit dem gcc-3.2.2 funktioniert es anstandslos (soweit ich weiß hat devc++ irgendeinen gcc-3.X unterliegend). Kann also eigentlich nur noch irgendwas total blödes sein, auf das ich nicht komme. Um wirklich alle Dummheiten auszuschließen:
- Kommentiere mal die beiden Standardheader in der main.cpp aus
- Starte den Präprozessor von der Kommandozeile aus:
cpp main.cpp main.i
cpp.exe müsste im selben Verzeichnis wie gcc.exe, ld.exe usw. liegen.
Guck dir die main.i mit einem Texteditor an. Ist das wirklich die richtige Rectangle.h die eingebunden wird?
-
Also wenn ich die beiden Standardheader und die Methoden welche selbige benötigen auskommentiere kompiliert er anstandslos. Heißt das ich brauche neue Standardheader? Wenn ja, woher?
-
ModjoMan schrieb:
Also wenn ich die beiden Standardheader und die Methoden welche selbige benötigen auskommentiere kompiliert er anstandslos. Heißt das ich brauche neue Standardheader? Wenn ja, woher?
Ich meinte eigentlich, du sollst erst die Standardheader auskommentieren und dann den Preprozessor drüberlaufen lassen, sonst hast du im Ergebnis (main.i) tausende von Zeilen, die dich nicht interessieren.
-
Mist, jetzt hab ich mir schon die SGI-STL in das Verzeichnis vom minGW kopiert und jetzt läuft garnichts mehr. Kann man die Dateien nicht einfach ersetzen?
-
Ok, hab DevC++ neu installiert.
-
Also laut main.i wird definitiv die richtige eingebunden
-
# 1 "main.cpp" # 1 "<built-in>" # 1 "<command line>" # 1 "main.cpp" # 1 "Rectangle.h" 1 class Rectangle { protected: double height, width; public: Rectangle(double h, double w); double circumference(); double surface(); }; # 6 "main.cpp" 2 int main() { cout << ">>>>> C++ 10.000.000 object creations & method calls" << endl; clock_t start = clock(); for(double i = 0; i < 10000000; ++i) { Rectangle r(i / (i + 1), i / (i + 2)); double x = r.surface(); x = r.circumference(); } clock_t end = clock(); cout << ">>>>> elapsed C++ user time: " << (end - start) << " ms.<<<<<" << endl; return 0; }
-
das gleiche problem hatte ich auch mal mit devcpp. als ich es dann ein paar tage später wieder probiert habe ging es aufeinmal, obwohl ich nichts verändert hatte. nachdem mir das 2 x passiert war bin ich auf c++builderX umgestiegen und jetzt hab ich keine probleme mehr.