I have some code that was previously compiled and working in C++Builder 6. I want to recompile it in 10.4.2 and build 32-bit and 64-bit Windows targets.
The existing code compiles using the classic compiler, but when I try to compile with the clang compiler, I am getting the dreaded ICE:
Internal compiler error: 0 @ 00000000
By using #ifdef
s to remove sections of code, I have tracked it down to the way the functions are declared. Nothing I have tried works, which makes me think I must have missed something very fundamental.
The original code that still works with the classic compiler:
extern "C" {
BOOL WINAPI __declspec(dllexport) GetLogonSIDFromToken (HANDLE hToken, PSID *ppsid);
BOOL WINAPI __declspec(dllexport) GetCurrentProcessLogonSID (PSID *ppsid);
BOOL WINAPI __declspec(dllexport) GetLogonSIDFromAccountName(char *lpszUserName, PSID *ppsid);
VOID WINAPI __declspec(dllexport) FreeLogonSID (PSID *ppsid);
PSECURITY_DESCRIPTOR WINAPI __declspec(dllexport) AddAceToNewSecurityDescriptor(PSECURITY_DESCRIPTOR psd, PSID psid, DWORD dwType, DWORD dwFlags, DWORD dwMask);
BOOL WINAPI __declspec(dllexport) SetUserObjectNullDacl(HANDLE hObject);
BOOL WINAPI __declspec(dllexport) AddAceToUserObject(HANDLE hObject, PSID psid, DWORD dwType, DWORD dwFlags, DWORD dwMask);
BOOL WINAPI __declspec(dllexport) AddAceToWindowStation(HWINSTA hwinsta, PSID psid);
BOOL WINAPI __declspec(dllexport) AddAceToDesktop(HDESK hdesk, PSID psid);
}
Now I have tried lots of things, and looked into the Windows SDK headers, but if I put this into my code:
extern "C" {
// this is lifted directly from winbase.h
WINADVAPI
BOOL
WINAPI
LogonUserExW (
_In_ LPCWSTR lpszUsername,
_In_opt_ LPCWSTR lpszDomain,
_In_opt_ LPCWSTR lpszPassword,
_In_ DWORD dwLogonType,
_In_ DWORD dwLogonProvider,
_Outptr_opt_ PHANDLE phToken,
_Outptr_opt_ PSID *ppLogonSid,
_Outptr_opt_result_bytebuffer_all_(*pdwProfileLength) PVOID *ppProfileBuffer,
_Out_opt_ LPDWORD pdwProfileLength,
_Out_opt_ PQUOTA_LIMITS pQuotaLimits
);
/*
BOOL
WINAPI
GetLogonSIDFromToken(
_In_ HANDLE hToken,
_Outptr_opt_ PSID *ppsid
);
*/
/*
BOOL
APIENTRY
GetLogonSIDFromToken(
_In_ HANDLE hToken,
_Outptr_opt_ PSID *ppsid
);
*/}
It compiles fine (but obviously doesn't have declarations for my functions), but if I uncomment either the second or third declaration, I get the ICE error.
Can anyone provide any pointers (no pun intended) for me, please?