Skip to content

Raylib example never enters main loop #226

@TibboddiT

Description

@TibboddiT

At least on my setup (x86_64-linux) the main loop is never entered.

After some inspection, I believe this is because WindowShouldClose() returns a bool, which has a size of 1 byte on my system, but the temporary variable holding the result of the call is 8 bytes (I think), and so it may contain garbage in the upper 7 bytes that will mess with the while condition.

    ...

    InitWindow(800, 600, "Hello, from B");
    SetTargetFPS(60);
    while (!WindowShouldClose()) { // <-- here
        if (IsKeyPressed(32)) {
            paused = !paused;
        }

    ...

After discovering that your compiler supports bits operations, I tested this hypothesis with this change:

     InitWindow(800, 600, "Hello, from B");
     SetTargetFPS(60);
-    while (!WindowShouldClose()) {
+    while (!(WindowShouldClose() & 1)) {
         if (IsKeyPressed(32)) {
             paused = !paused;
         }

And it worked as intended.

I feel that making extrn function declarations aware of the full function signature (with args and return types) is not aligned with the spirit of the project, and so manually handling non word sized external values seems the way to go. I can make a PR if necessary.

Very cool project by the way. The compiler's hack / test / debug cycle is top notch. And the btest output is crazy good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions