You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Converting defines into enums where possible would enable the use of the -Wenum-enversion compiler option to detect cases where one this is being used for something it's not.
Some other compiler options already enabled with -Wall would also trigger on bad usage of enumified defines.
Currently the preproc used in the expansion can't handle enums in some parts of the code. A PR is available to fix this in the base pret pokeemerald, but the comments on that make some valid points regarding the preproc. So that would need to be addressed before the "enumification" could be done.
By merging that PR, replacing all #define TYPE_XXXX with an enum with all of them worked with no other changes for compiling the ROM, tests on the other hand failed to compile. It also fails to compile with agbcc.
Discord contact info
hedara
The text was updated successfully, but these errors were encountered:
Just stating it here so we don't forget, imo anything that ends up being stored in the save should have explicit values, e.g. enum SpeciesID { SPECIES_NONE = 0, ... }; rather than just enum SpeciesID { SPECIES_NONE, ... };. This is because reordering the values would break saves, so having the friction of all the numbers being explicit will hopefully help discourage downstream users and well-meaning contributors from doing that by accident.
Just stating it here so we don't forget, imo anything that ends up being stored in the save should have explicit values, e.g. enum SpeciesID { SPECIES_NONE = 0, ... }; rather than just enum SpeciesID { SPECIES_NONE, ... };. This is because reordering the values would break saves, so having the friction of all the numbers being explicit will hopefully help discourage downstream users and well-meaning contributors from doing that by accident.
If that's the case, why even make them enums to begin with?
It might be clearer that constants stored in the save use #define while those that aren't use enum.
If that's the case, why even make them enums to begin with?
-Wenum-conversion will give you an error if you pass an enum of the wrong type to a function/assign it to a variable.
EDIT: And -Wswitch (enabled by -Wall) will warn you if you have a switch (x) where x is an enum and your cases don't cover all the options.
Description
Converting
define
s intoenum
s where possible would enable the use of the-Wenum-enversion
compiler option to detect cases where one this is being used for something it's not.Some other compiler options already enabled with
-Wall
would also trigger on bad usage ofenum
ifieddefine
s.Currently the
preproc
used in the expansion can't handleenum
s in some parts of the code. A PR is available to fix this in the base pret pokeemerald, but the comments on that make some valid points regarding thepreproc
. So that would need to be addressed before the "enumification" could be done.By merging that PR, replacing all
#define TYPE_XXXX
with anenum
with all of them worked with no other changes for compiling the ROM, tests on the other hand failed to compile. It also fails to compile withagbcc
.Discord contact info
hedara
The text was updated successfully, but these errors were encountered: