在我的代码中,我有一个 wchar_t 数组:
wchar_t paths [6] = {L"C:\\Program Files\\SomeAppsSuiteFolder1", L"C:\\Program Files\\SomeAppsSuiteFolder2", L"C:\\Program Files (x86)\\SomeAppsSuiteFolder1", L"C:\\Program Files (x86)\\SomeAppsSuiteFolder2", L"C:\\SomeAppsSuiteFolder1", L"C:\\SomeAppsSuiteFolder2"};
稍后我在for
循环中使用数组。问题是,对于这一行,我得到以下错误:
error: too many initializers for 'wchar_t [6]'
error: initializer-string for array of chars is too long [-fpermissive]
更重要的是,在for
循环中我有这样的if
条件:
if(GetFileAttributesW(paths[i])!=INVALID_FILE_ATTRIBUTES) {...}
而且,我在这里再次遇到错误:
error: invalid conversion from 'wchar_t' to 'LPCWSTR {aka const wchar_t*}' [-fpermissive]
奇怪的是,几个月前用于正确编译的类似代码......有什么问题?