Skip to content

Commit

Permalink
added --stack-first for better stack overflows, see rustwasm/team#81
Browse files Browse the repository at this point in the history
  • Loading branch information
L0laapk3 committed Aug 29, 2021
1 parent 6a613a6 commit a2c9474
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mkdir build
-Wl,--no-entry ^
-Wl,--import-memory ^
-Wl,--strip-all ^
-Wl,--stack-first ^
-fvisibility=hidden ^
-Ofast ^
--sysroot="wasi-sdk/share/wasi-sysroot" ^
Expand Down
9 changes: 1 addition & 8 deletions src/interface.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
#pragma once

#include "position.h"


enum Shape {
Circle = 0,
Square = 1,
Triangle = 2,
};

#include "shape.h"


#define IMPORT(module, name) __attribute__((import_module(module), import_name(name)))
Expand Down
9 changes: 7 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@



float persistentTest;

EXPORT("tick")
void tick(int tick, bool initialize) {
println("cpp is awesome! tick: %i", tick);
// println("cpp is awesome! tick: %i", tick);

if (initialize)
persistentTest = 0;

auto myId = Interface::Player::me();

Expand All @@ -15,7 +20,7 @@ void tick(int tick, bool initialize) {
for (int i = 0; i < Interface::Spirit::count(); i++) {
if (Interface::Spirit::playerId(i) == myId) {
Interface::Spirit::shout(i, "cpp 💖");
Interface::Spirit::move(i, baseX, baseY);
Interface::Spirit::move(i, baseX, persistentTest++);
Interface::Spirit::energizeBase(i, 0);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/shape.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

enum Shape {
Circle = 0,
Square = 1,
Triangle = 2,
};

0 comments on commit a2c9474

Please sign in to comment.