MrSmith33 / vox

Vox language compiler. AOT / JIT / Linker. Zero dependencies
Boost Software License 1.0
327 stars 18 forks source link

Importing file with extern attributes causes "External function cannot have a body" error #16

Closed judah-caruso closed 2 years ago

judah-caruso commented 2 years ago

I may be misunderstanding how @extern can be used, but the following program results in an error.

// main.vox
#version(windows) {
    import win;
}

void main() {
    #version(windows) ExitProcess(0);
}
// win.vox
@extern(module, "kernel32")
void ExitProcess(u32 uExitCode);

@extern(module, "kernel32")
void* GetStdHandle(u32 nStdHandle);

// ...

Command: vox main.vox win.vox [location of kernel32.dll]

Output:

win.vox:1:1: Error: External function cannot have a body

Copying and pasting the contents of win.vox into main.vox fixes this.

MrSmith33 commented 2 years ago

Hello. Thanks for report!

@extern(module, "kernel32") feature is still not implemented, but the External function cannot have a body error here is a bug. I will fix this soon, but for the time being omit the @extern attribute and will work.