Can not use Directory::GetCurrentDirectory() in C++?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Why ?

void foo()
{
Directory::GetCurrentDirectory() ;
}
----------Compile Error-----------------------
C2039: 'GetCurrentDirectoryA' : is not a member
of 'System::IO::Directory'
 
Why ?

void foo()
{
Directory::GetCurrentDirectory() ;
}
----------Compile Error-----------------------
C2039: 'GetCurrentDirectoryA' : is not a member
of 'System::IO::Directory'

You've #included <windows.h>, which #defines GetCurrentDirectory as a macro
that expands to either GetCurrentDirectoryA or GetCurrentDirectoryW.

It's best to avoid using Win32 API names in your own code to avoid such
problems, but you can also just #undef GetCurrentDirectory after your
#includes.

-cd
 
Back
Top