OFFICIAL GML Consistency in GMS2 v2.2.2

Josepho

Member
It should be a warning instead of an error, now i have a 10 K code line project with lots of potential crashes. If you cast as real a string without numbers should be 0! thats how lots of languages work! For example casting a "" as real now gives a crash (imagine a csv file processed where blank numbers are assumed to be treaten as 0), very very bad decision yoyo¡¡¡
 

GMWolf

aka fel666
FWIW, chars are not ints.

Try this in C

Code:
if(sizeof(char) == sizeof(int))
    std::cout << "I stand corrected";
Well on my machine that works.
Because an int is define to be at least the size of a short. And a short is defined to be at least the size of a char.
 

Storyteller

Member
in C, as in ANSI C, a 'char' is an 'int'. C != C++
there are some differences in implementation, but in general, 'chars' are represented as integers. not even just 'binary numbers', actual integers.
most operations and functions on chars work with or return ints. Ive been reading up on this lately.

you may have different types, different sizes, but the specification declares chars as 'a minimum size of integers', depending on your platform or compiler.
By 'spec', all chars in C, are ints.
most often they map to standard ASCII. your mileage may vary, but for the most part this is true.

'A' + 1 = 'B';

consider this man page on 'getchar'; it returns an int.
https://linux.die.net/man/3/getchar

edit: grammar, added link
 
Last edited:
Top