It would help if you can let me know the exact installable package name of MinGW-w64 compilers and the link.
 
 
Regards,
Milind


 
On Wed, Nov 7, 2012 at 10:35 PM, Christian Franke <Christian.Franke@t-online.de> wrote:
Andreas Mohr wrote:


Andreas Mohr wrote:
Since possibly nobody else has done a reply yet,
I'll try to have a Q&D best-effort job on it
(note that I don't have any reference material here,
thus it's all from recollection).

I already answered yesterday:
http://sourceforge.net/mailarchive/message.php?msg_id=30063859




WTS*() in MinGW headers might be incomplete, or they might be
improperly specified in regards to Windows version defines
(e.g. WINVER, _WIN32_WINNT etc.) that enable them conditionally.

Yes.

There are actually *two* independent bugs in include/wtsapi32.h from w32api-3.17-2-mingw32-dev.tar.lzma
(http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/w32api-3.17/)

1. Parse error on _WIN32_WINNT=0x0500

2. Wrong linkage for WTSSendMessage()


Testcase:

$ cat wtstest.c
#include <windows.h>
#include <wtsapi32.h>

int main()
{
DWORD res;
WTSSendMessageA(0, 1, "Title", 5, "Test", 4, MB_OK, 0, &res, FALSE);
return 0;
}

$ gcc -D_WIN32_WINNT=0x0500 wtstest.c -lwtsapi32
In file included from wtstest.c:2:0:
./wtsapi32.h:82:3: error: expected specifier-qualifier-list before ‘WTS_CONNECTSTATE_CLASS’
./wtsapi32.h:88:3: error: expected specifier-qualifier-list before ‘WTS_CONNECTSTATE_CLASS’
./wtsapi32.h:117:74: error: expected declaration specifiers or ‘...’ before ‘WTS_INFO_CLASS’
./wtsapi32.h:119:74: error: expected declaration specifiers or ‘...’ before ‘WTS_INFO_CLASS’

$ gcc -D_WIN32_WINNT=0x0501 wtstest.c -lwtsapi32
/tmp/ccda22dX.o:wtstest.c:(.text+0x5e): undefined reference to `_WTSSendMessageA'
collect2: ld returned 1 exit status

$ nm lib/libwtsapi32.a | grep -w _WTSSendMessageA
00000000 T _WTSSendMessageA@40 // <== stdcall/WINAPI linkage


$ cat include/wtsapi32.h
...
#if (_WIN32_WINNT >= 0x0501)
...
typedef enum ... { ...
} WTS_CONNECTSTATE_CLASS;
...
#endif /* _WIN32_WINNT >= 0x0501 */

#if (_WIN32_WINNT >= 0x0500)

typedef struct _WTS_SESSION_INFOW {
DWORD SessionId;
LPWSTR pWinStationName;
WTS_CONNECTSTATE_CLASS State; // <== undefined if _WIN32_WINNT=0x0500
} WTS_SESSION_INFOW, *PWTS_SESSION_INFOW;
...
BOOL WTSSendMessageA( // <== C linkage, missing WINAPI
...
#endif /* _WIN32_WINNT >= 0x0500 */


Conclusion: Due to 2nd bug, build of smartmontools r3584 or later with MinGW requires a fixed version of this include file.

Due to its x64 support, I have already moved the build process for testing (on Cygwin) and packaging (on Linux) from MinGW to MinGW-w64. No problems since then.

Thanks,
Christian