Gast
#422551
Hallo, was bedeutet: array subscribt has type `char'
|
Anzeige
|
Warning
Gast
#422551
Hallo, was bedeutet: array subscribt has type `char' hallo, bischen kurze beschreibung, aber vermutlich verwendest du als array-index ein 'char' statt wie "richtig" einen 'int'. hth, bye kosmo
Gast
#422565
hi kosmo, wenig Text, aber Du hast es trotzdem genau getroffen. Gruß Michael Aus dem GCC-Manual:
-Wchar-subscripts
Warn if an array subscript has type "char". This is a common cause
of error, as programmers often forget that this type is signed on
some machines. This warning is enabled by -Wall.
Der Punkt ist: wenn du ein "char" hast, das implizit wie "signed char"
behandelt wird (das ist die Voreinstellung beim AVR-GCC), dann werden
Werte >= 128 bei der impliziten Typumwandlung, die beim Zugriff auf ein
Array vorgenommen wird, zu negativen Indizes. Das willst du nicht
wirklich so haben, denke ich mir. ;-)
Es ist aber völlig OK, ein uint8_t (aus <stdint.h>) als Index zu nehmen.
Antwort schreiben |
Anzeige
|