Re: Compiler Warnung

"Sascha 'saigkill' Manns" <[email protected]>
Newsgroups gmane.linux.suse.programming
Organization openSUSE Marketing Team
Message-ID <[email protected]>
On Montag 16 März 2009 19:10:53 Philipp Thomas wrote:
> Hallo Sascha,
>
> * Sascha 'saigkill' Manns ([email protected]) [20090316 17:43]:
> > #else
> >     return false;
> > #endif
> > } <- Das ist Zeile 358
>
> Der Compiler kann nicht erkennen, das alle möglichen Fälle im switch
> abgehandelt werden, also beschwert er sich, dass hier ein Verlassen
> der Funktion ohne Rückgabewert möglich ist.
>
> > Kann ich hier auch return false oder return 0 eingeben?
> > Ich habe die cpp Datei mal angehangen...
>
> Ich würde etwas weiter oben bei
>
>     case NoBattery:
>          // we have no way to determine if we're on batteries,
>          // so we say we aren't
>         return false;
>
> einfach noch default: hinzufügen:
>
>     case NoBattery:
>     default:
>          // we have no way to determine if we're on batteries,
>          // so we say we aren't
>         return false;
>
> Dann "sieht" der Compiler, das alle möglichen Fälle abgedeckt sind.
Hat wunderbar funktioniert. Vielen Dank :-)

-- 
Sincereley yours

Sascha Manns
openSUSE Marketing Team
openSUSE Build Service
Web: http://saschamanns.gulli.to
Project-Blog: http://lizards.opensuse.org/author/saigkill
Private-Blog: http://saschasbacktrace.blogspot.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.