Andrew Wiley wrote:
I'm trying to use the Windows file change notification API from D, and
I'm having trouble translating Microsoft's macro-laden signatures into
D. I thought I had it figured out, but optlink says otherwise:
The original function is this:

HANDLE WINAPI FindFirstChangeNotification(
  __in  LPCTSTR lpPathName,
  __in  BOOL bWatchSubtree,
  __in  DWORD dwNotifyFilter
);

I translated it into:

extern(Windows) {
uint FindFirstChangeNotification(
        const(char)* lpPathName,
        bool bWatchSubtree,
        uint dwNotifyFilter
);
}

Optlink is giving me undefined symbol errors, but I can't seem to
figure out what I have wrong. Any help would be appreciated.

Here is the declaration from \dm\include\win32\winbase.h:

WINBASEAPI
HANDLE
WINAPI
FindFirstChangeNotificationA(
    LPCSTR lpPathName,
    BOOL bWatchSubtree,
    DWORD dwNotifyFilter
    );
WINBASEAPI
HANDLE
WINAPI
FindFirstChangeNotificationW(
    LPCWSTR lpPathName,
    BOOL bWatchSubtree,
    DWORD dwNotifyFilter
    );
#ifdef UNICODE
#define FindFirstChangeNotification  FindFirstChangeNotificationW
#else
#define FindFirstChangeNotification  FindFirstChangeNotificationA
#endif // !UNICODE

Note the W postfix and the LPCWSTR arg, which should be wchar* (in D).

With the Digital Mars C compiler, getting the de-macro'd version is easy:

    dmc -c foo.c -e -l

and the macro expanded version will be written to foo.lst. Very handy.

Reply via email to