FILE_NAME_INFO was not declared in this scope
Dec 27, 2017 at 5:40pm UTC
hi guys I'm just bored so I decided to mess around a little testing functions and classes from different headers
anyway I ran into an error when I tried creating a struct from the windows.h header file
I'm not sure why _FILETIME will work with no problems but I can't create a struct from _FILE_NAME_INFO
main.cpp|14|error: '_FILE_NAME_INFO' was not declared in this scope|
thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <stdio.h>
#include <windows.h>
#include <security.h>
#include <iostream>
#include <limits>
#include <ctime>
using namespace std;
int main()
{
_FILE_NAME_INFO i;
_FILETIME file;
cout << file.dwLowDateTime << endl;
cout << file.dwHighDateTime << endl;
}.
Dec 27, 2017 at 6:24pm UTC
When I remove #include <security.h> it works on VS 2015
Dec 27, 2017 at 7:30pm UTC
I tried removing secuirty.h from the includes but still no luck
I am using codeblocks so maybe I need a certain flag set on my compiler?
Dec 27, 2017 at 8:11pm UTC
fwiw: it doesn't work on my version of mingw as well (which is probably what you're using as well, since you mentioned codeblocks). Not sure what the issue is. I guess gcc might just not support it.
Edit: The struct definition is located inside include/winbase.h (which is included with windows.h), but it's only defined if
1 2 3 4 5 6 7 8 9
#if _WIN32_WINNT >= 0x0600
#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
// ...
typedef struct _FILE_NAME_INFO {
DWORD FileNameLength;
WCHAR FileName[1];
} FILE_NAME_INFO,*PFILE_NAME_INFO;
My _WIN32_WINNT returns a number smaller than 0x0600 (1536). I think an additional SDK or something is needed?
BTW, _WIN32_WINNT >= 0x0600 is supposed to mean "If version is greater than Windows Vista"
See:
https://msdn.microsoft.com/en-us/library/6sehtctf.aspx
Last edited on Dec 27, 2017 at 8:32pm UTC
Dec 27, 2017 at 8:22pm UTC
yes I'm using mingw
thanks Gnado
Dec 27, 2017 at 8:40pm UTC
Apparently you might just need to override the macro definition yourself if you want to support it.
http://www.mingw.org/wiki/Use_more_recent_defined_functions You need to set defines _WIN32_WINDOWS, _WIN32_WINNT, WINVER and/or _WIN32_IE to the minimum platform you plan to support before including the windows.h header file. Possible values for these definitions can be found in the header w32api.h file.
Last edited on Dec 27, 2017 at 8:43pm UTC
Topic archived. No new replies allowed.