LingDong- / wax

A tiny programming language that transpiles to C, C++, Java, TypeScript, Python, C#, Swift, Lua and WebAssembly 🚀
https://waxc.netlify.app/
MIT License
783 stars 45 forks source link

How to #include with C backend? #18

Closed phillvancejr closed 3 years ago

phillvancejr commented 3 years ago

How can I get a valid #include for C?

(asm "#include \"some_file.h\"")
(func main (result int)
    (return 0)
)

gives malformed include

#include "some_file.h"int main() {
    return 0;
}

I tried using an escaped newline and escaping the backslash in the newline but this was included raw into the final output instead of actually escaping a new line

(asm "#include \"some_file.h\"\n")
(func main (result int)
    (return 0)
)

gives

#include "some_file.h"\nint main() {
    return 0;
}
phillvancejr commented 3 years ago

This works

(asm "#include \"some_file.h\"
")
(func main (result int)
    (return 0)
)

Its not what I expected but does make sense 😄