FILE_NAME_INFO was not declared in this scope

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;

}.
When I remove #include <security.h> it works on VS 2015
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?
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
yes I'm using mingw

thanks Gnado
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
Registered users can post here. Sign in or register to post.