I am trying to compile a program in Visual Studio 2010 in Windows 7. I am getting a compilation error C2061: syntax error: identifier ‘KNOWN_FOLDER_FLAG’ in Windows header shlobj.h at the marked line:
#if (NTDDI_VERSION >= NTDDI_VISTA)
typedef enum
{
KF_FLAG_DEFAULT = 0x00000000,
KF_FLAG_CREATE = 0x00008000,
KF_FLAG_DONT_VERIFY = 0x00004000,
KF_FLAG_DONT_UNEXPAND = 0x00002000,
KF_FLAG_NO_ALIAS = 0x00001000,
KF_FLAG_INIT = 0x00000800,
KF_FLAG_DEFAULT_PATH = 0x00000400,
KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200,
KF_FLAG_SIMPLE_IDLIST = 0x00000100,
KF_FLAG_ALIAS_ONLY = 0x80000000,
} KNOWN_FOLDER_FLAG;
DEFINE_ENUM_FLAG_OPERATORS(KNOWN_FOLDER_FLAG);
STDAPI SHGetKnownFolderIDList(__in REFKNOWNFOLDERID rfid,
__in DWORD /* KNOWN_FOLDER_FLAG */ dwFlags,
__in_opt HANDLE hToken,
__deref_out PIDLIST_ABSOLUTE *ppidl);
STDAPI SHSetKnownFolderPath(__in REFKNOWNFOLDERID rfid,
__in DWORD /* KNOWN_FOLDER_FLAG */ dwFlags,
__in_opt HANDLE hToken,
__in PCWSTR pszPath);
STDAPI SHGetKnownFolderPath(__in REFKNOWNFOLDERID rfid,
__in DWORD /* KNOWN_FOLDER_FLAG */ dwFlags,
__in_opt HANDLE hToken,
__deref_out PWSTR *ppszPath);
#endif // NTDDI_VISTA
#if (NTDDI_VERSION >= NTDDI_WIN7)
STDAPI SHGetKnownFolderItem(__in REFKNOWNFOLDERID rfid,
__in KNOWN_FOLDER_FLAG flags, <<<ERROR AT THIS LINE
__in_opt HANDLE hToken,
__in REFIID riid,
__deref_out void **ppv);
#endif // NTDDI_WIN7
In my program the version macros is defined as folows
#define NTDDI_VERSION NTDDI_WINXP
What can be the reason for it not to compile?
It seems to me that the part I am getting the error in must not be compiled at all, but it somehow does.
There is only one logical conclusion: for some reason the expansion of
NTDDI_VERSIONwhen this header is compiled is not what you think it is.Try troubleshooting by searching for
#undef NTDDI_VERSIONand making a clean build of your project (might be relevant if you are using precompiled headers).