Browse Source

fixed windows include path

rlbr-dev
Larry Xue 5 years ago
parent
commit
51bc3410b9
  1. 3
      README.md
  2. 10
      c2logic/compiler.py

3
README.md

@ -31,7 +31,8 @@ Special Variables:
- `__rbx`: stores left hand side of binary ops to avoid clobbering by the right side
- `__retaddr__<func_name>`: stores return address of func call
When writing your code, you must include `c2logic/builtins.h`, which is located in the python include directory (location depends on system, mine is at `~/.local/include/python3.8/`). A quick way to find this is `python3 -c 'import sysconfig, os; print(sysconfig.get_path("include",f"{os.name}_user"))'`.
When writing your code, you must include `c2logic/builtins.h`, which is located in the python include directory (location depends on system, mine is at `~/.local/include/python3.8/`).
A quick way to find this is `python3 -c "from c2logic.compiler import get_include_path; print(get_include_path())"` (use `python` if you are using windows).
See [include/builtins.h](./include/builtins.h) for API definitions and [examples](./examples) for API sample usage.

10
c2logic/compiler.py

@ -58,7 +58,7 @@ class Compiler(c_ast.NodeVisitor):
ast = parse_file(
filename,
use_cpp=True,
cpp_args=["-I", sysconfig.get_path("include", f"{os.name}_user")]
cpp_args=["-I", get_include_path()]
)
self.visit(ast)
@ -431,6 +431,14 @@ class Compiler(c_ast.NodeVisitor):
else:
raise NotImplementedError(node)
def get_include_path():
if os.name == "posix":
return sysconfig.get_path("include", "posix_user")
elif os.name == "nt":
return sysconfig.get_path("include", "nt")
else:
raise ValueError(f"Unknown os {os.name}")
def main():
import argparse
parser = argparse.ArgumentParser()

Loading…
Cancel
Save