Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Emscripten build #854

Closed
wants to merge 3 commits into from
Closed

Fix Emscripten build #854

wants to merge 3 commits into from

Conversation

Birch-san
Copy link

@Birch-san Birch-san commented Dec 8, 2024

Fixes #855.

encountered this compile error when using build_emscripten.sh:

[ 55%] Building C object src/CMakeFiles/box2d.dir/timer.c.o
cd /Users/birch/git/box2d/build/src && /Users/birch/git/emsdk/upstream/emscripten/emcc -DBOX2D_ENABLE_SIMD @CMakeFiles/box2d.dir/includes_C.rsp -g -std=gnu17 -fvisibility=hidden -ffp-contract=off -msimd128 -msse2 -Werror -MD -MT src/CMakeFiles/box2d.dir/timer.c.o -MF CMakeFiles/box2d.dir/timer.c.o.d -o CMakeFiles/box2d.dir/timer.c.o -c /Users/birch/git/box2d/src/timer.c
/Users/birch/git/box2d/src/timer.c:90:8: error: no member named 'start_sec' in 'struct b2Timer'
   90 |         timer.start_sec = t.tv_sec;
      |         ~~~~~ ^
/Users/birch/git/box2d/src/timer.c:91:8: error: no member named 'start_usec' in 'struct b2Timer'
   91 |         timer.start_usec = t.tv_usec;
      |         ~~~~~ ^
/Users/birch/git/box2d/src/timer.c:99:28: error: no member named 'start_sec' in 'struct b2Timer'
   99 |         time_t start_sec = timer->start_sec;
      |                            ~~~~~  ^
/Users/birch/git/box2d/src/timer.c:100:47: error: no member named 'start_usec' in 'struct b2Timer'
  100 |         suseconds_t start_usec = (suseconds_t)timer->start_usec;
      |                                               ~~~~~  ^
/Users/birch/git/box2d/src/timer.c:123:28: error: no member named 'start_sec' in 'struct b2Timer'
  123 |         time_t start_sec = timer->start_sec;
      |                            ~~~~~  ^
/Users/birch/git/box2d/src/timer.c:124:47: error: no member named 'start_usec' in 'struct b2Timer'
  124 |         suseconds_t start_usec = (suseconds_t)timer->start_usec;
      |                                               ~~~~~  ^
/Users/birch/git/box2d/src/timer.c:141:9: error: no member named 'start_sec' in 'struct b2Timer'
  141 |         timer->start_sec = t.tv_sec;
      |         ~~~~~  ^
/Users/birch/git/box2d/src/timer.c:142:9: error: no member named 'start_usec' in 'struct b2Timer'
  142 |         timer->start_usec = t.tv_usec;
      |         ~~~~~  ^
8 errors generated.
make[2]: *** [src/CMakeFiles/box2d.dir/timer.c.o] Error 1
make[1]: *** [src/CMakeFiles/box2d.dir/all] Error 2
make: *** [all] Error 2

seems like timer.c expects to be able to assign to start_sec, start_usec when __EMSCRIPTEN__ is defined, so I've declared those propeties on b2Timer in that circumstance.

@ErikSom
Copy link

ErikSom commented Dec 8, 2024

Awesome!

@erincatto
Copy link
Owner

Similar fixes in #852

@erincatto erincatto closed this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build_emscripten.sh compile error accessing b2Timer.start_sec
4 participants