PolyMarsDev / Terri-Fried

A multi-platform C++ game made for Ludum Dare 46
200 stars 55 forks source link

type 'double' cannot be narrowed to 'int' in initializer list [-Wc++11-narrowing] #23

Open LucasMW opened 2 years ago

LucasMW commented 2 years ago

main.cpp:17:93: warning: variable 'player' is uninitialized when used within its own initialization [-Wuninitialized] ...player(platforms[0].getX() + platforms[0].getWidth()/2 - 26/2, platforms[0].getY() - player...


main.cpp:318:50: error: type 'double' cannot be narrowed to 'int' in initializer
      list [-Wc++11-narrowing]
  ...SDL_Rect platformSprite_rect = { platforms[i].getX(), platforms[i].getY(...
                                      ^~~~~~~~~~~~~~~~~~~
main.cpp:318:50: note: insert an explicit cast to silence this issue
  ...SDL_Rect platformSprite_rect = { platforms[i].getX(), platforms[i].getY(...
                                      ^~~~~~~~~~~~~~~~~~~
                                      static_cast<int>(  )
main.cpp:318:71: error: type 'double' cannot be narrowed to 'int' in initializer
      list [-Wc++11-narrowing]
  ...platformSprite_rect = { platforms[i].getX(), platforms[i].getY(), 100, 3...
                                                  ^~~~~~~~~~~~~~~~~~~
main.cpp:318:71: note: insert an explicit cast to silence this issue
  ...platformSprite_rect = { platforms[i].getX(), platforms[i].getY(), 100, 3...
                                                  ^~~~~~~~~~~~~~~~~~~
                                                  static_cast<int>(  )
main.cpp:327:44: error: type 'double' cannot be narrowed to 'int' in initializer
      list [-Wc++11-narrowing]
            SDL_Rect playerSprite_rect = { player.getX(), player.getY()...
                                           ^~~~~~~~~~~~~
main.cpp:327:44: note: insert an explicit cast to silence this issue
            SDL_Rect playerSprite_rect = { player.getX(), player.getY()...
                                           ^~~~~~~~~~~~~
                                           static_cast<int>( )
main.cpp:327:59: error: type 'double' cannot be narrowed to 'int' in initializer
      list [-Wc++11-narrowing]
  ...SDL_Rect playerSprite_rect = { player.getX(), player.getY(), 32, 32 };
                                                   ^~~~~~~~~~~~~
main.cpp:327:59: note: insert an explicit cast to silence this issue
  ...SDL_Rect playerSprite_rect = { player.getX(), player.getY(), 32, 32 };
                                                   ^~~~~~~~~~~~~
                                                   static_cast<int>( )
main.cpp:330:45: error: type 'double' cannot be narrowed to 'int' in initializer
      list [-Wc++11-narrowing]
            SDL_Rect lavaSprite_rect = { 0, lavaY, 800, 48 };
                                            ^~~~~
main.cpp:330:45: note: insert an explicit cast to silence this issue
            SDL_Rect lavaSprite_rect = { 0, lavaY, 800, 48 };
                                            ^~~~~
                                            static_cast<int>( )
1 warning and 5 errors generated.
mandar1jn commented 2 years ago

what compier are you using?