locked
Help!Compiling errors: 'WIN32_FIND_DATA' : undeclared identifier RRS feed

  • Question

  • I got a lot of compiling errors when building my project:

    error C2065: 'WIN32_FIND_DATA' : undeclared identifier
    error C2146: syntax error : missing ';' before identifier 'find_data'
    error C2065: 'find_data' : undeclared identifier
    error C2065: 'find_data' : undeclared identifier
    error C3861: 'FindFirstFile': identifier not found
    error C2065: 'INVALID_HANDLE_VALUE' : undeclared identifier
    error C2065: 'find_data' : undeclared identifier
    error C2228: left of '.dwFileAttributes' must have class/struct/union type is ''unknown-type''
    error C2065: 'find_data' : undeclared identifier
    error C2228: left of '.cFileName' must have class/struct/union type is ''unknown-type''
    error C2065: 'find_data' : undeclared identifier
    error C2228: left of '.cFileName' must have class/struct/union type is ''unknown-type''
    error C3861: 'GetLastError': identifier not found
    error C2660: 'fbe_file_read' : function does not take 3 arguments
    error C2065: 'find_data' : undeclared identifier
    error C2228: left of '.cFileName' must have class/struct/union type is ''unknown-type''

    I'm working under windows7. Does anyone has any idea of what happens to me?

    Thanks!


    Tuesday, March 20, 2012 12:56 PM

Answers

  • You have to include windows.h
    • Proposed as answer by BenoitRoosens Tuesday, March 20, 2012 1:20 PM
    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 12:59 PM
  • Can you post your includes? 2 possible options:
    1. Remove includes already included by Windows.h
    2. Include Windows.h first

    Let us know!

    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 2:04 PM
  • Make <windows.h> the first include file, or the second right after <stdafx.h>

    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 3:17 PM
  • Isn't the best practice to place the #include <Windows.h> directive right at the top of stdafx.h?
    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 3:19 PM

All replies

  • You have to include windows.h
    • Proposed as answer by BenoitRoosens Tuesday, March 20, 2012 1:20 PM
    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 12:59 PM
  • You have to include windows.h

    In fact, after I include the <windows.h>, hundreds of macro redefinitions appears(below list is part of them), so I thought the <windows.h> has been included in other head files and delete it.

    My code has include some head files and those may include others recursively which I don't know clearly. I'm not sure whether there're conflicts. Do you know how to resolve it?

    C:\WinDDK\7600.16385.0\inc\api\ntdef.h(149) : error C2220: warning treated as error - no 'object' file generated

    C:\WinDDK\7600.16385.0\inc\api\ntdef.h(149) : warning C4005: 'PROBE_ALIGNMENT' : macro redefinition C:\MSSDK\v7.0\include\winnt.h(130) : see previous definition of 'PROBE_ALIGNMENT'

    C:\WinDDK\7600.16385.0\inc\api\ntdef.h(157) : warning C4005: 'PROBE_ALIGNMENT32' : macro redefinition

    C:\MSSDK\v7.0\include\winnt.h(138) : see previous definition of 'PROBE_ALIGNMENT32'

    C:\WinDDK\7600.16385.0\inc\api\ntdef.h(614) : error C2011: '_PROCESSOR_NUMBER' : 'struct' type redefinition

    C:\MSSDK\v7.0\include\winnt.h(493) : see declaration of '_PROCESSOR_NUMBER'

    C:\WinDDK\7600.16385.0\inc\api\ntdef.h(625) : error C2011: '_GROUP_AFFINITY' : 'struct' type redefinition

    C:\MSSDK\v7.0\include\winnt.h(504) : see declaration of '_GROUP_AFFINITY'

    C:\WinDDK\7600.16385.0\inc\api\ntdef.h(882) : error C2011: '_FLOAT128' : 'struct' type redefinition

    C:\MSSDK\v7.0\include\winnt.h(630) : see declaration of '_FLOAT128'

    C:\WinDDK\7600.16385.0\inc\api\ntdef.h(933) : error C2011: '_LARGE_INTEGER' : 'union' type redefinition

    Tuesday, March 20, 2012 1:32 PM
  • Something wrong with headers, that’s for sure. What is the type of your project? Which libraries are you using in the project? What have you done before it stops compiling? :)
    Tuesday, March 20, 2012 1:54 PM
  • Can you post your includes? 2 possible options:
    1. Remove includes already included by Windows.h
    2. Include Windows.h first

    Let us know!

    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 2:04 PM
  • Make <windows.h> the first include file, or the second right after <stdafx.h>

    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 3:17 PM
  • Isn't the best practice to place the #include <Windows.h> directive right at the top of stdafx.h?
    • Marked as answer by anaconda_wly Wednesday, March 21, 2012 2:50 AM
    Tuesday, March 20, 2012 3:19 PM
  • It's very kind of you all.

    This is a part of a very large project. There're many recursive head files including and libraries linking. So I didn't know exactly in a short term.

    WinDDK maybe used. I wonder whether "WinDDK\7600.16385.0\inc\api\ntdef.h"  &  "MSSDK\v7.0\include\winnt.h" will conflict.

    Tuesday, March 20, 2012 11:36 PM