eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.26k stars 612 forks source link

Compilation error for Windows #555

Closed NtAllocateVirtualMemory closed 2 weeks ago

NtAllocateVirtualMemory commented 2 weeks ago

With x86_64-w64-mingw32:

  File "/usr/lib/python3.12/site-packages/pycparser/plyparser.py", line 67, in _parse_error
    raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: /usr/x86_64-w64-mingw32/sys-root/mingw/include/vadefs.h:24:28: before: __gnuc_va_list
raw = parse_file(
                source,
                use_cpp  = True,
                cpp_path = 'x86_64-w64-mingw32-gcc',
                cpp_args = [
                    '-E',
                    '-std=c99',
                    '-municode',
                    '-I' + utils_dir,
                    '-I' + curent_dir
                ]
            )

With clang on Windows:

  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\pycparser\plyparser.py", line 67, in _parse_error
    raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.40.33807\\include\\vadefs.h:61:34: before: uintptr_t
raw = parse_file(
                source,
                use_cpp  = True,
                cpp_path = 'clang',
                cpp_args = [
                    '-E',
                    '-std=c99',
                    '-municode',
                     '-I' + utils_dir,
                     '-I' + curent_dir
                ]
            )

C source code:

#include <windows.h>

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) 
{
    AddVectoredExceptionHandler(1, &Demo);
    RemoveVectoredExceptionHandler(&Demo);
    WaitForSingleObject((HANDLE)-1, INFINITE);
}
eliben commented 2 weeks ago

Please read this section: https://github.com/eliben/pycparser?tab=readme-ov-file#31interaction-with-the-c-preprocessor and the next one after it very carefully