OpenFodder / openfodder

Open Fodder: An open source port of Cannon Fodder
http://openfodder.com
GNU General Public License v3.0
459 stars 42 forks source link

Compilation on Raspberry Pi requires -fsigned-char #4

Closed zerojay closed 8 years ago

zerojay commented 8 years ago

When compiling latest OpenFodder on a Raspberry Pi 2, I received a ton of errors regarding a "constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char) [-Wc++11-narrowing].

I had to add -fsigned-char into the CC = line in the Makefile to get it to compile properly.

segrax commented 8 years ago

Hey Zerojay,

Which line(s) do some of these occur with? i would be interested in investigating the cause before applying this fix, just in-case it causes bugs elsewhere

zerojay commented 8 years ago

It's actually very possible that I ran into side effects of applying it everywhere as the game currently segfaults for me when I'm midway through the second level consistently with this fix applied. With the fix removed and also with the 100 errors flag removed (to try get all of them), I have the following:

clang++ -c -Wall -std=c++0x -I/usr/include/directfb/direct -I/usr/include/directfb -I./Source/ sdl2-config --cflags Source/.cpp Source/PC/.cpp Source/Amiga/.cpp Source/Fodder.cpp:1308:14: warning: unused variable 'Data24' [-Wunused-variable] sRecruit Data24 = &mRecruits[mRecruit_NextID]; ^ Source/Fodder.cpp:2665:22: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (mSurfaceMapTop < 0)


Source/Fodder.cpp:2672:23: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if (mSurfaceMapLeft < 0)
                    ~~~~~~~~~~~~~~~ ^ ~
Source/Fodder.cpp:3305:11: warning: unused variable 'Data2C' [-Wunused-variable]
        sSprite\* Data2C = dword_3B4CF;
                 ^
Source/Fodder.cpp:13009:22: warning: cast to 'sSprite _' from smaller integer type 'int16' (aka 'short') [-Wint-to-pointer-cast]
        dword_3B213[0x0E] = (sSprite_) Data0;
                            ^
Source/Fodder.cpp:16705:8: warning: unused variable 'Data28' [-Wunused-variable]
        int8\* Data28 = 0;
              ^
Source/Fodder.cpp:16944:8: warning: unused variable 'Data0' [-Wunused-variable]
        int16 Data0;
              ^
Source/Fodder.cpp:20496:22: warning: unused variable 'Data14' [-Wunused-variable]
        int16 Data8, DataC, Data14, Data4, Data10;
                            ^
8 warnings generated.
Source/Recruits.cpp:27:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "JOOLS ", '\x02', '\xFF', '\x04' },
                      ^~~~~~
Source/Recruits.cpp:27:23: note: insert an explicit cast to silence this issue
  { "JOOLS ", '\x02', '\xFF', '\x04' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:28:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "JOPS  ", '\x02', '\xFF', '\x06' },
                      ^~~~~~
Source/Recruits.cpp:28:23: note: insert an explicit cast to silence this issue
  { "JOPS  ", '\x02', '\xFF', '\x06' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:29:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "STOO  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:29:23: note: insert an explicit cast to silence this issue
  { "STOO  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:30:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "RJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:30:23: note: insert an explicit cast to silence this issue
  { "RJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:31:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "UBIK  ", '\x02', '\xFF', '\x01' },
                      ^~~~~~
Source/Recruits.cpp:31:23: note: insert an explicit cast to silence this issue
  { "UBIK  ", '\x02', '\xFF', '\x01' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:32:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "CJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:32:23: note: insert an explicit cast to silence this issue
  { "CJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
                      ^~~~~~
Source/Recruits.cpp:28:23: note: insert an explicit cast to silence this issue
  { "JOPS  ", '\x02', '\xFF', '\x06' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:29:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "STOO  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:29:23: note: insert an explicit cast to silence this issue
  { "STOO  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:30:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "RJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:30:23: note: insert an explicit cast to silence this issue
  { "RJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:31:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "UBIK  ", '\x02', '\xFF', '\x01' },
                      ^~~~~~
Source/Recruits.cpp:31:23: note: insert an explicit cast to silence this issue
  { "UBIK  ", '\x02', '\xFF', '\x01' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:32:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "CJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:32:23: note: insert an explicit cast to silence this issue
  { "CJ    ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:33:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "CHRIS ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:33:23: note: insert an explicit cast to silence this issue
  { "CHRIS ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:34:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "PETE  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:34:23: note: insert an explicit cast to silence this issue
  { "PETE  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:35:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "TADGER", '\x03', '\xFF', '\x03' },
                      ^~~~~~
Source/Recruits.cpp:35:23: note: insert an explicit cast to silence this issue
  { "TADGER", '\x03', '\xFF', '\x03' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:36:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "HECTOR", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:36:23: note: insert an explicit cast to silence this issue
  { "HECTOR", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:37:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "ELROY ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:37:23: note: insert an explicit cast to silence this issue
  { "ELROY ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
                      ^~~~~~
Source/Recruits.cpp:33:23: note: insert an explicit cast to silence this issue
  { "CHRIS ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:34:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "PETE  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:34:23: note: insert an explicit cast to silence this issue
  { "PETE  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:35:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "TADGER", '\x03', '\xFF', '\x03' },
                      ^~~~~~
Source/Recruits.cpp:35:23: note: insert an explicit cast to silence this issue
  { "TADGER", '\x03', '\xFF', '\x03' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:36:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "HECTOR", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:36:23: note: insert an explicit cast to silence this issue
  { "HECTOR", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:37:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "ELROY ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:37:23: note: insert an explicit cast to silence this issue
  { "ELROY ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:38:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "SOFTY ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:38:23: note: insert an explicit cast to silence this issue
  { "SOFTY ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:39:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "MAC   ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:39:23: note: insert an explicit cast to silence this issue
  { "MAC   ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:40:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "BOMBER", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:40:23: note: insert an explicit cast to silence this issue
  { "BOMBER", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:41:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "STAN  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:41:23: note: insert an explicit cast to silence this issue
  { "STAN  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:42:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "TOSH  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:42:23: note: insert an explicit cast to silence this issue
  { "TOSH  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:43:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "BRAINS", '\x02', '\xFF', '\x01' },
                      ^~~~~~
Source/Recruits.cpp:43:23: note: insert an explicit cast to silence this issue
  { "BRAINS", '\x02', '\xFF', '\x01' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:44:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "NORM  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:44:23: note: insert an explicit cast to silence this issue
  { "NORM  ", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
Source/Recruits.cpp:45:23: error: constant expression evaluates to 255 which cannot be narrowed to type 'int8' (aka 'signed char') [-Wc++11-narrowing]
  { "BUSTER", '\x02', '\xFF', '\0' },
                      ^~~~~~
Source/Recruits.cpp:45:23: note: insert an explicit cast to silence this issue
  { "BUSTER", '\x02', '\xFF', '\0' },
                      ^~~~~~
                      static_cast<int8>( )
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Source/stdafx.cpp:45:2: warning: delete called on 'cFodder' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
        delete Fodder;
        ^
1 warning generated.
Makefile:16: recipe for target 'main' failed
make: **\* [main] Error 1

I tried to remove the -ferror-limit but it still ended up stopping. Let me know if there's anything I can do to help.
segrax commented 8 years ago

\xFF with -1,

I'll do that when I'm back at a computer

segrax commented 8 years ago

I'll fix some of these other warnings will I'm at it :)

segrax commented 8 years ago

Give that a try, i've just replaced all those '\xFF' with -1

zerojay commented 8 years ago

I can confirm that you've fixed the compilation issues.

segrax commented 8 years ago

Cheers!

symbios24 commented 5 years ago

hello i cannot really find a port of openfodder to download or instructions to build it for Raspberry Pi, you say in your main page: Ports for OpenBSD and RetroPie are available but there is not any link

thanks