Skip to content

emscripten_request_animation_frame_loop using Bool type and conflicting with legacy code #22916

@Buggem

Description

@Buggem

Please include the following in your bug report:

Version of emscripten/emsdk:
3.1.71

The problem is in my program, bools used to be defined like this in a header file:

typedef enum {false, true} boolean;

And for whatever reason importing emscripten.h conflicts with that, even though it is boolean and not bool. When compiling the file I added Emscripten's header into, the compiler gives this error.

emcc  -m32 -O3 -g -s USE_SDL=2 -Wall -DNORMALUNIX -DLINUX -DSDL  -c d_main.c -o linux/d_main.o
In file included from d_main.c:49:
In file included from ./doomstat.h:33:
In file included from ./doomdata.h:28:
./doomtype.h:34:15: error: expected identifier
   34 | typedef enum {false, true} boolean;
      |               ^
/home/runner/work/_temp/593f506f-5435-42e1-b4a8-af6c31095bf8/emsdk-main/upstream/lib/clang/20/include/stdbool.h:26:15: note: expanded from macro 'false'
   26 | #define false 0
      |               ^
In file included from d_main.c:49:
In file included from ./doomstat.h:33:
In file included from ./doomdata.h:28:
./doomtype.h:34:22: error: expected identifier
   34 | typedef enum {false, true} boolean;
      |                      ^
/home/runner/work/_temp/593f506f-5435-42e1-b4a8-af6c31095bf8/emsdk-main/upstream/lib/clang/20/include/stdbool.h:25:14: note: expanded from macro 'true'
   25 | #define true 1
      |              ^
d_main.c:163:18: warning: multiple unsequenced modifications to 'eventhead' [-Wunsequenced]
  163 |     eventhead = (++eventhead)&(MAXEVENTS-1);
      |               ~  ^
d_main.c:180:51: warning: multiple unsequenced modifications to 'eventtail' [-Wunsequenced]
  180 |     for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) )
      |                                                ~  ^
2 warnings and 2 errors generated.

So I had to change the definition to this to please Emscripten.

#include <stdbool.h>
typedef bool boolean;

But that did not please my program, since it has many errors where it compares booleans to ints and vice versa, some of which are not pointed out by the compiler.

I personally can't wrangle the spaghetti source code of the program I am planning to port to Emscripten, because of a lack of C experience. If not a bug, is there any way I can fix this conflict without resorting to the newer C99 bindings and making major modifications?

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