vnmakarov / mir

A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR
MIT License
2.24k stars 147 forks source link

__GNU_LIBRARY__ macro branch isn't good in mirc_x86_64_stdarg.h. #321

Closed Kray-G closed 1 year ago

Kray-G commented 1 year ago

I want to thank you for providing the very fantastic product of MIR.

Today, I found a problem that I've failed compiling with c2m.exe, and I figured out it depending on __WIN32 macro when I digged into the c2m source. As a conclution, _WIN32 is defined but __WIN32 isn't defined in the Microsoft compilers, so I found you should use _WIN32 instead.

Please feel free to ask me if you have any questions.

Kray-G commented 1 year ago

I am sorry, _WIN32 was not good for the Windows build because my project has been broken with the code. Now I'm trying to find a correct fix, but both the orginal code with __WIN32 and the new code with _WIN32 are incorrect so far. Concretely, after I replaced __WIN32 by _WIN32, c2m.exe couldn't find __va_start.

Now, I've got it works when removing __GNU_LIBRARY__ from mirc_x86_64_stdarg.h.

Looking at other places in mirc_x86_64_stdarg.h, there's no other __GNU_LIBRARY__ macro in that file, that means you'll find out all branches by the macro is separated by #else instead of using __GNU_LIBRARY__ macro. So now, I think this place should have #else instead of #elif __GNU_LIBRARY__. At least there is no #else of that macro branch.

Although I think __WIN32 is not correct, it remains because it's original.

I'll try to find the correct way, but anyway could you make it back to #else?

Kray-G commented 1 year ago

I am so sorry, I will clean it up once and recreate the pull request after that.