Skip to content

Commit 4ace4ee

Browse files
committed
Fix build on windows
1 parent ca9cbc4 commit 4ace4ee

7 files changed

Lines changed: 31 additions & 12 deletions

File tree

INSTALL.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ Build the executable:
2222
```
2323
make ExecuteFile
2424
.\bin\executefile.exe .\mfiles\addition.m
25+
```
26+
27+
```
28+
# Windows MINGW
29+
https://winlibs.com/
2530
```

makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# -rdynamic for backtrace support
22

3-
SHARED_FLAGS := -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Werror -O0 -std=c++17 -rdynamic -ggdb
3+
SHARED_FLAGS := -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Werror -O0 -std=c++17 -ggdb
44

55
ifdef OS
66
# Windows
77
CXXFLAGS := ${SHARED_FLAGS} -DWIN
88
else
99
# Unix
10-
CXXFLAGS := ${SHARED_FLAGS}
10+
CXXFLAGS := ${SHARED_FLAGS} -rdynamic
1111
endif
1212

1313
CXX := g++
@@ -60,7 +60,6 @@ Build: BuildMLang BuildTests Lib
6060

6161
Clean:
6262
ifdef OS
63-
# Windows
6463
$(foreach file, $(OBJS), -del $(subst /,\,${file}) >nul 2>&1;)
6564
$(foreach file, $(EXES), -del $(subst /,\,${file}) >nul 2>&1;)
6665
else

src/error/Exceptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#define WIN32_LEAN_AND_MEAN
55
#include <windows.h>
66
#include <stdio.h>
7-
void print_stacktrace();
8-
{
7+
void print_stacktrace()
8+
{
99
const ULONG framesToSkip = 0;
1010
const ULONG framesToCapture = 64;
1111
void* backTrace[framesToCapture] {};
@@ -21,7 +21,7 @@ void print_stacktrace();
2121
for(USHORT iFrame = 0; iFrame < nFrame; ++iFrame) {
2222
printf("[%3d] = %p\n", iFrame, backTrace[iFrame]);
2323
}
24-
printf("backTraceHash = %08x\n", backTraceHash);
24+
printf("backTraceHash = %08lx\n", backTraceHash);
2525
}
2626
#else
2727
#include <execinfo.h> /* backtrace, backtrace_symbols_fd */

src/executer/ByteCode.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88

99
#include "../executer/ExternalFunctions.h"
1010
#include "../error/Exceptions.h"
11+
#include "Types.h"
1112
#include "Stack.h"
1213

1314
namespace executor {
1415

15-
using word_t = unsigned long;
16-
static_assert(sizeof(word_t) == 8);
17-
1816
enum class Op {
1917
NOP,
2018
LOCALS,

src/executer/ExternalFunctions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#include "../executer/ExternalFunctions.h"
2+
3+
4+
#ifdef WIN
5+
// Windows
6+
#else
27
#include <dlfcn.h>
8+
#endif
39

410
namespace ffi {
511

src/executer/Stack.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
#include <vector>
44
#include "../error/Exceptions.h"
5+
#include "Types.h"
56

67
namespace executor {
7-
8-
// TODO: Duplicate of src/executer/ByteCode.h
9-
using word_t = unsigned long;
108

119
class Stack {
1210
private:

src/executer/Types.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
namespace executor {
4+
5+
#ifdef WIN
6+
using word_t = unsigned long long;
7+
#else
8+
using word_t = unsigned long;
9+
#endif
10+
11+
static_assert(sizeof(word_t) == 8);
12+
13+
} // namespace executor

0 commit comments

Comments
 (0)