Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LucasMW opened this issue Sep 10, 2021 · 1 comment

Comments

@LucasMW
Copy link

LucasMW commented Sep 10, 2021

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( )
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( )
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( )
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( )
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( )
1 warning and 5 errors generated.

@mandar1jn
Copy link

what compier are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants