Closed LordNoteworthy closed 2 months ago
The SAL annotations are defined in mingw-w64-headers/include/sal.h as empty macros. Those are not required in mingw toolchain.
Thanks a lot @Biswa96 for your answer.
Yes, I understand that they are not required for mingw toolchain, I was wondering if I can re-generate the headers so that they includes those SAL annotations or somehow modify the code.
Just to put some context, I am using the mingw headers just to parse the Windows APIs, and I happen to need those annotations. I am not really compiling anything, just parsing the header files.
As you know, those SAL annotations only works in MSVC and obviously don't make sense to have them in mingw headers. I am asking just to get some idea or feedback from developers who are familiar with the mingw codebase and recommend some hack I can do to have them.
Cheers.
I am using the mingw headers just to parse the Windows APIs
That seems new to me. Would you like to explain the requirement? Maintainers may provide some information.
I work on an Win32 API tracer. It hooks APIs so we can log them. To be able to that, I need the prototypes of all Windows APIs, something like this: https://github.com/saferwall/winsdk2json/blob/main/assets/apis.json
I am the author of that repo, I was able to obtain that data simply by using regex. However sometimes, the Windows APIs get quiet complex and it is very hard to extract the functions prototypes without having a proper C language parser.
So I started using https://github.com/zchee/cznic-ccgo which takes a C code as input and translate it to an AST.
I had issues with parsing the Windows SDK directly, because that library cannot deal with a lot of MS compiler specific features and its more tested against GCC toolchain. That's what brought me to this project.
Now I can extract all the prototypes that I need:
...
DWORD GetFileVersionInfoSizeExA (DWORD dwFlags,LPCSTR lpwstrFilename,LPDWORD lpdwHandle,)
DWORD GetFileVersionInfoSizeExW (DWORD dwFlags,LPCWSTR lpwstrFilename,LPDWORD lpdwHandle,)
WINBOOL GetFileVersionInfoA (LPCSTR lptstrFilename,DWORD dwHandle,DWORD dwLen,LPVOID lpData,)
WINBOOL GetFileVersionInfoW (LPCWSTR lptstrFilename,DWORD dwHandle,DWORD dwLen,LPVOID lpData,)
WINBOOL GetFileVersionInfoExA (DWORD dwFlags,LPCSTR lpwstrFilename,DWORD dwHandle,DWORD dwLen,LPVOID lpData,)
WINBOOL GetFileVersionInfoExW (DWORD dwFlags,LPCWSTR lpwstrFilename,DWORD dwHandle,DWORD dwLen,LPVOID lpData,)
DWORD VerLanguageNameA (DWORD wLang,LPSTR szLang,DWORD nSize,)
DWORD VerLanguageNameW (DWORD wLang,LPWSTR szLang,DWOR
...
The only thing I am missing is those SAL annotations.
I apologies because this issue is a bit out of topic, please feel free to close the issue.
Cheers.
i guess you would have to use msvc headers instead.. no?
That's the only way yeah, thanks @Kreijstal
Hello,
If we compare the prototypes from the Windows SDK:
Versus the minGW ones:
You can see SAL annotations missing. Is there any way to generate them with those annotations ?
Cheers.