Enums



  • Hallo,

    ich lese gerade zum zweiten mal der C++ Programmierer von Ulrich Breymann und bin bei Enums angekommen und sehe schon direkt das erste Problem, seitdem ich eine neue IDE nutze.

    Code:

    #include <iostream>
    
    enum class Farbtyp {rot, gruen, blau, gelb};
    
    int main() {
    	Farbtyp hell;
    
    	hell = Farbtyp::gelb;
    
    	return 0;
    }
    

    Fehlermeldung:

    C:\WINDOWS\system32\cmd.exe /C C:/MinGW/32-bit/bin/make.exe -j4 SHELL=cmd.exe -e -f Makefile
    "----------Building project:[ Tutorial - Debug ]----------"
    make.exe[1]: Entering directory 'C:/Users/AMD-Power/Documents/Programmierung/workspaces/CodeLite/C++/Tutorial'
    C:/MinGW/32-bit/bin/g++.exe -c "C:/Users/AMD-Power/Documents/Programmierung/workspaces/CodeLite/C++/Tutorial/main.cpp" -g -O0 -Wall -pedantic -Wfatal-errors -o ./Debug/main.cpp.o -I. -I.
    C:/Users/AMD-Power/Documents/Programmierung/workspaces/CodeLite/C++/Tutorial/main.cpp:3:1: warning: scoped enums only available with -std=c++11 or -std=gnu++11
    enum class Farbtyp {rot, gruen, blau, gelb};
    ^
    C:/Users/AMD-Power/Documents/Programmierung/workspaces/CodeLite/C++/Tutorial/main.cpp: In function 'int main()':
    C:/Users/AMD-Power/Documents/Programmierung/workspaces/CodeLite/C++/Tutorial/main.cpp:8:9: error: 'Farbtyp' is not a class or namespace
    hell = Farbtyp::gelb;
    ^
    compilation terminated due to -Wfatal-errors.
    make.exe[1]: *** [Debug/main.cpp.o] Error 1
    make.exe: *** [All] Error 2
    Tutorial.mk:97: recipe for target 'Debug/main.cpp.o' failed
    make.exe[1]: Leaving directory 'C:/Users/AMD-Power/Documents/Programmierung/workspaces/CodeLite/C++/Tutorial'
    Makefile:4: recipe for target 'All' failed
    ====2 errors, 1 warnings====

    Der selbe Code funktioniert in CodeBlocks und Visual Studio super, aber nicht in CodeLite seltsam.

    MfG Venek



  • Du musst c++11 aktivieren, wie es die Fehlermeldung sagt. Wie das in CodeLite hab ich keine Ahnung.



  • Ich habe schon versucht klappt nicht. Ich habe sogar -std=c++14 eingeschaltet. Daselbe auch in CodeBlocks und dort klappt es super.



  • Dieser Thread wurde von Moderator/in Arcoth aus dem Forum C++ (alle ISO-Standards) in das Forum Compiler- und IDE-Forum verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.





  • Danke, es klappt habe versehntlich in die falsche Zeile geschrieben 😃


Anmelden zum Antworten