Skip to content

Invalid Signed Integer Literal (-2147483648) in RenderingServer.hpp Causes Cross-Compiler Error #1822

Closed

Description

@CycloneRing

Godot version

4.5.beta

godot-cpp version

latest

System information

Windows 11 - MSVC

Issue description

There's a compiler issue after adding CANVAS_LAYER_MIN to godot-cpp, After compiling the library and headers there will be :

	static const int CANVAS_LAYER_MIN = -2147483648;
	static const int CANVAS_LAYER_MAX = 2147483647;

Which causes error in compile :

godot_cpp\classes\rendering_server.hpp(805,38): error C4146: unary minus operator applied to unsigned type, result still unsigned.

Here's the lines from extension_api.json

{
	"name": "CANVAS_LAYER_MIN",
	"value": -2147483648 <- TYPO
},
{
	"name": "CANVAS_LAYER_MAX",
	"value": 2147483647
}

Steps to reproduce

  1. Clone godot-cpp repo
  2. Build
  3. Link against GDExtension with usage of Rendering Server

How to fix :

Change -2147483648 to -2147483647 or use (-2147483647 - 1)

Activity

  1. changed the title [-]Non-Portable Integer Literal in RenderingServer.hpp (-2147483648) Causes Compile Error[/-] [+]Invalid Signed Integer (Typo) Literal (-2147483648) in RenderingServer.hpp Causes Cross-Compiler Error[/+] on Jul 21, 2025
  2. CycloneRing commented on Jul 21, 2025

    @CycloneRing
    Author

    Okay it's a issue in engine itself, closing this and make a new one to engine.

  3. CycloneRing commented on Oct 25, 2025

    @CycloneRing
    Author

    Issue still exists in 4.6 @dsnopek can you please check this.
    On both msvc and clangcl i get the error for CANVAS_LAYER_MIN

    godot_cpp\classes\rendering_server.hpp(814,38): error C4146: unary minus operator applied to unsigned type, result still unsigned

    At generated rendering_server.hpp :

    static const int CANVAS_LAYER_MIN = -2147483648; <- HERE
    static const int CANVAS_LAYER_MAX = 2147483647;

    It must be generated like this

    static const int CANVAS_LAYER_MIN = (-2147483647 - 1);
    static const int CANVAS_LAYER_MAX = 2147483647;
  4. changed the title [-]Invalid Signed Integer (Typo) Literal (-2147483648) in RenderingServer.hpp Causes Cross-Compiler Error[/-] [+]Invalid Signed Integer Literal (-2147483648) in RenderingServer.hpp Causes Cross-Compiler Error[/+] on Oct 25, 2025
  5. dsnopek commented on Nov 1, 2025

    @dsnopek
    Collaborator

    Thanks!

    However, I'm not sure I understand why this is an error?

    The value of CANVAS_LAYER_MIN is -2147483648 in Godot itself:

    https://github.com/dsnopek/godot/blob/c0c1c685621971c75c0f0f4aab85e8293c67a993/servers/rendering/rendering_server.h#L105

    This is the code generated currently in godot-cpp:

    static const int CANVAS_LAYER_MIN = -2147483648;
    

    This is a signed integer, and, as far as I know, -2147483648 is a valid value for a signed 32-bit integer.

    Whereas the error says "unary minus operator applied to unsigned type, result still unsigned"

    Why does it think this integer is unsigned? And why does switching to (-2147483647 - 1) somehow fix that?

  6. CycloneRing commented on Nov 2, 2025

    @CycloneRing
    Author

    @dsnopek You're right that -2147483648 is a valid signed 32-bit value, but the issue is how the compiler parses it. 2147483648 exceeds INT32_MAX, so it's treated as an unsigned literal... Applying unary minus to that triggers the error: "unary minus operator applied to unsigned type, result still unsigned." on msvc and msclang.

    Using (-2147483647 - 1) avoids this by staying within signed literal bounds and evaluating correctly at compile time. It's a common workaround for expressing INT32_MIN safely across compilers.

  7. dsnopek commented on Feb 1, 2026

    @dsnopek
    Collaborator

    I just posted PR #1919 which should fix this, although, I don't personally have one of the compiler versions or configurations that errors on this

  8. added
    bug
    on Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions