Closed architector1324 closed 1 year ago
Looks like there are some warnings caused integers type coercion.
$ make g++ -c spell.cpp -o obj/spell.o -g g++ -c text_field.cpp -o obj/text_field.o -g g++ -c object_defs.cpp -o obj/object_defs.o -g g++ -c state.cpp -o obj/state.o -g g++ -c object.cpp -o obj/object.o -g object.cpp: В функции-члене «void object::act(effect_def, effect)»: object.cpp:99:34: предупреждение: narrowing conversion of «(int)(e.effect::timed.effect::<unnamed struct>::time >> 1)» from «int» to «int16_t» {aka «short int»} [-Wnarrowing] 99 | e.timed.time >> 1, | ~~~~~~~~~~~~~^~~~ object.cpp:100:28: предупреждение: narrowing conversion of «(rand() % ((int)e.effect::timed.effect::<unnamed struct>::amount))» from «int» to «int16_t» {aka «short int»} [-Wnarrowing] 100 | rand() % e.timed.amount | ~~~~~~~^~~~~~~~~~~~~~~~ object.cpp:110:65: предупреждение: narrowing conversion of «(int)(e.effect::timed.effect::<unnamed struct>::time >> 1)» from «int» to «int16_t» {aka «short int»} [-Wnarrowing] 110 | equipment[i].stat.act(def, {false, e.timed.time >> 1, 0}); | ~~~~~~~~~~~~~^~~~ object.cpp: В функции-члене «bool object::check_enemy(object*)»: object.cpp:37:1: предупреждение: управление достигает конца не-void функции [-Wreturn-type] 37 | } | ^ g++ -c classes.cpp -o obj/classes.o -g g++ -c items.cpp -o obj/items.o -g g++ -c actions.cpp -o obj/actions.o -g actions.cpp: В функции «void act_punch(object*, object*)»: actions.cpp:27:48: предупреждение: narrowing conversion of «* value» from «int» to «int16_t» {aka «short int»} [-Wnarrowing] 27 | target->act({0,1,CRUSH_ATTACK}, {0, 0, *value}); | ^~~~~~ g++ -c effect_calc.cpp -o obj/effect_calc.o -g g++ -c card.cpp -o obj/card.o -g g++ -c user_ifc.cpp -o obj/user_ifc.o -g user_ifc.cpp: В функции «bool user_turn(object*, screen)»: user_ifc.cpp:197:49: предупреждение: передача NULL в неуказательный аргумент 3 в «object* search_targets(object*, screen, size_t)» [-Wconversion-null] 197 | search_targets(NULL, s, NULL); | ^~~~ In file included from user_ifc.hpp:3, from user_ifc.cpp:2: card.hpp:46:54: замечание: declared here 46 | object* search_targets(object* obj, screen s, size_t range); | ~~~~~~~^~~~~ g++ -c scene.cpp -o obj/scene.o -g g++ -c main.cpp -o obj/main.o -g g++ obj/*.o -o test -lncurses -lpanel -g
Fix:
stdint.h
short
unsigned int
static_cast
Also it is a good idea to add -Wall -Werror compilation flags to the makefile.
-Wall -Werror
Hello @architector1324, There was many warning reports (~140 lines of g++ output). I fixed it in the last commit on master. Thanks for your advice.
Looks like there are some warnings caused integers type coercion.
Fix:
stdint.h
types instead oldshort
,unsigned int
, etc.static_cast
.Also it is a good idea to add
-Wall -Werror
compilation flags to the makefile.