ThKattanek / emu64

C64 Emulator
https://www.thorsten-kattanek.de/index.php/projekte/emu64
GNU General Public License v2.0
38 stars 6 forks source link

narrowing conversion when `char` is not signed #191

Closed Zirias closed 4 years ago

Zirias commented 4 years ago

Building fails on architectures with unsigned char like powerpc:

../../emu64-5.0.18/src/c64_class.cpp: In member function 'void 
C64Class::AnalyzeSDLEvent(SDL_Event*)':
../../emu64-5.0.18/src/c64_class.cpp:1760:46: error: narrowing conversion of '-1' from 'int' to 'char' [-Wnarrowing]
 1760 |     static char joy_axis_tbl[5] = {1,1,0,0,-1};
      |                                              ^
*** [c64_class.o] Error code 1

Suggestion: explicitly use unsigned char and signed char where appropriate.

Reported from: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245200

ThKattanek commented 4 years ago

Ok, I always assumed that char == unsigned char. But just checked my C / C ++ Reference again. ANSI does not specify whether char is signed or not. I will correct that, maybe I have used more of it. I'll go through everything. Thank you!

ThKattanek commented 4 years ago

this is fixed. I'll look at the rest of the source code tomorrow.