Hat schon jemand den selben Fehler gahabt??



  • void functionname(HMENU handle, int id)
    {
    int i1, i2;
    
    switch((long)handle)
    {
    case ((long)hSounds):
    	i1 = 0; //hier ist zeile 2238
    	i2 = 14;
    	break;	
    
    case ((long)hColors):
    	i1 = 16;
    	i2 = 17;
    }
    }
    

    Generierte felermeldung:
    Error E2313 C:\projekt.cpp 2238: Constant expression required in function functionname(HMENU__ *,int)

    Wäre nett wenn jmd. sagen könnte wo der Fehler liegt. Ich sehe keinen..
    Mfg.



  • Ganz einfach: Das Schlüsselwort 'case' erlaubt nur Konstanten. 'hSounds' und 'hColors' sind in deinem Fall jedoch Variablen, deshalb lässt es sich nicht kompilieren.



  • Danke Aziz!

    Habe den switch durch 2 ifs ersetzt nun klappts...

    if (handle==hColors)
    	{
    	i1 = 0;
    	i2 = 14;
    	}
    if (handle==hSounds)
    	{
    	i1 = 16;
    	i2 = 17;
    	}
    

Anmelden zum Antworten