ERROR: ISO C++ forbids declaration of 'FricCalcn' with no type [-fpermissive]
-
Hallo Leute,
ich habe zu dem Fehler schon viele viele Beiträge gelesen, aber nichts hilft mir weiter. Ich seh den Wald vor lauter Bäumen ned mehr.
Hoffentlich könnt ihr mir helfen:
main.cpp
/* includes */ #include <iostream> /* includes headers */ #include "main.h" using namespace std; int main() { FricCalc classe; cout << "Klasseninstanz wurde angelegt" << endl; classe.Set_axMax(5); cout << "axMax wurde auf 5 vorinitialisiert." << endl; classe.Set_ayMax(3); cout << "ayMax wurde auf 3 vorinitialisiert." << endl; classe.Set_Ax(2); cout << "ax wurde auf 2 vorinitialisiert." << endl; classe.Set_Ay(1); cout << "ay wurde auf 1 vorinitialisiert." << endl; cout << "Berechnung wird durchgeführt." << endl; int i = FricCalcn(); cout << "Ergebnis der Berechnung lautet: " << classe.Get_fricRaw() << endl; return 0; }
main.h
#ifndef MAIN_H #define MAIN_H /* includes */ #include "Calcn.h" #endif
Calcn.h
#ifndef CALCN_H #define CALCN_H /* includes */ #include "main.h" /* functions */ int FricCalcn(); // Calculation of friction value /* classes */ class FricCalc { float m_ax; // weitere variablen void init_array(float* bitAry); // function for initialization of array public: // Constructor FricCalc(); FricCalc(float ax, ...){ m_ax = ax; ... init_array(fricDetMaxFlgAry); } // Getters float Get_Ax() { return m_ax;} ... // Setters void Set_Ax(float ax) { m_ax = ax;} ... // Functions float Det_Max(float old, float neww) { return (neww > old)?neww:old;} float Det_Min(float *Ary); }; #endif /* CALCN_H */
Calcn.cpp
/* includes */ #include <iostream> /* includes headers */ #include "main.h" using namespace std; /* ----- Functions ----- */ int FricCalcn(){ // AxMax / AyMax float axmax = classe.Det_Max(classe.Get_axMax(), classe.Get_Ax()); classe.Set_AxMax(axmax); // Save new max value float aymax = classe.Det_Max(classe.Get_ayMax(), classe.Get_Ay()); classe.Set_AyMax(aymax); float fricRaw = square ( pow( (FacC * classe.Get_Ax() ),2) + pow(100,2) * pow(classe.Get_Ay() ,2) ) / ConstG ; classe.Set_fricRaw(fricRaw); cout << "Berechnung erfolgreich abgeschlossen" << endl; return 0; } ...
Fehler:
Calcn.h:30:130: error: ISO C++ forbids declaration of 'FricCalcn' with no type [-fpermissive] main.cpp: In function 'int main()': main.cpp:18:2: error: 'FricCalc' was not declared in this scope main.cpp:18:19: error: expected ';' before 'classe' main.cpp:23:2: error: 'classe' was not declared in this scope main.cpp:36:28: error: void value not ignored as it ought to be
-
Wozu dient der Header main.h, außer dazu, dir Zirkelschlüsse einzufangen?
-
Ich hab alles stark gekürzt...
Im header sind noch alle Konstanten und alle anderen Header inkludiert
-
Meine Beobachtung über Zirkelschlüsse gilt aber nach wie vor.
-
Was genau sind denn Zirkelschlüsse ?
Falls du das mehrmalige Inkludieren meinst ...
deswegen habe ich überall ifndef's drin und alle anderen header nur in der main.h inkludiert
-
Wenn du nicht mal kompilierbaren Code postest können wir dir nicht helfen. Bitte reduziere den Fehler auf ein Minimalbeispiel.
-
linux-freak schrieb:
Falls du das mehrmalige Inkludieren meinst ...
deswegen habe ich überall ifndef's drin und alle anderen header nur in der main.h inkludiertDann versuch mal nachzuvollziehen, was da wie genau expandiert wird. Du wirst feststellen, dass die ifdefs da überhaupt nichts bringen. Die sind für was anderes gut.