_findfirst() prototype changes

I recently noticed a difference in the function _findfirst()

From msdn we have:

VC6:

long
_findfirst( char *filespec, struct _finddata_t *fileinfo );

VC2005:

intptr_t
_findfirst(
   const char *filespec,
   struct _finddata_t *fileinfo
);

Since I need to build code to support multiple versions of VC++ I need some way to distinguish which version to use. Otherwise I end up getting type problems which results in either warnings or errors.

Should I filter for compiler version in preprocessing or is there another method

Thanks in advance.
Henrik Goldman
X-Formation (http://www.x-formation.com)



Answer this question

_findfirst() prototype changes

  • joop

    Well, of course the reason we changed that (I was wrongly assuming it was the addition of the const qualfication that was tripping you up) is that it is wrong in the Windows 64 bit model where pointers are 64 bits and long stays 32 bits. Windows handles also went to 64 bits.

    Of course we do not have a shipping version of 6.0 that targets 64 bit versions of Windows, so your fix is "safe" in that way.

    Ronald

  • BrunoCO

    And is there any chance of having an official (and safe) definition of that in an official header file

    Thanks,

    Jantje.

  • Cillian

    The problem is that VC6 doesn't understand intptr_t.

    So In order to get it working I had to do the following which seems to work fine:

    #if _MSC_VER == 1200 /* VC++ 6.0 doesn't understand intptr_t */

    typedef long intptr_t;

    #endif

    ...

    intptr_t pFile;

    ...

    if ((pFile = _findfirst(szFullPath, &FindData)) != -1)
    ...


  • Will Buchanan

    Hi,

    Why would you get type problems Any call site that satisfies the current declaration would also work with the 6.0 version of the declaration. We did quite a bit of work on cost correctness after 6.0 shipped.

    Ronald Laeremans
    Visual C++ team

  • _findfirst() prototype changes