godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Fix header generation for global constants

Open timothyqiu opened this issue 3 years ago • 1 comments

When writing https://github.com/godotengine/godot/pull/68999, I realized something in the generated global_constants.hpp will fail CI.

  1. The generated constants are int, but should be int64_t instead.

  2. Using INT64_MIN (-9223372036854775808) as a constant value produces warnings like:

    integer constant is so large that it is unsigned.

    This is because the negative sign is not part of the integer literal, and the largest signed integer type is long long, which can't hold 9223372036854775808.

    So for INT64_MIN, I break the literal into -9223372036854775807 - 1.

  3. Global constant names like UINT64_MAX will produce errors because these names are macros in C++. I think escaping them by prepending an underscore is okay since these constants all have their C++ counterpart, and won't be used often.

timothyqiu avatar Nov 22 '22 13:11 timothyqiu

Waiting for.

CsloudX avatar Jun 30 '23 02:06 CsloudX