Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual C++ Scope Bug?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I´ve a member function, CreateFile in my BS_Directory class which Visual C++ seems to confuse with its CreateFile somehow..

in class BS_Directory definition I´ve:
BS_File *CreateFile(string name, BS_File::BS_FileAccess access = BS_File::BS_ReadAccess);


And in my BS_File.cpp file I´ve the implementation of my CreateFile:

BS_File *BS_Directory::CreateFile(string name, BS_File::BS_FileAccess access)
{
...

ms_file = ::CreateFile(...);
...
}

I get the following error from Visual C++:

bs_file.cpp(321) : error C2039: 'CreateFileA' : is not a member of 'BS_Directory'

Now this is weird to say the least...
Thanks in advance!
/Julien
 
I´ve tried to change the name to CreateAFile and then all works, so it seems to be some confusions with Windows CreateFile...

/Julien
 
There is nothing weird about that.
As you know there is no effective CreateFile function - it only exists:
CreateFileA - normal
CreateFileW - for unicode, wide chars and so on.

In one of the predefined header files that you include (probably windows.h) there is a phrase like:

#ifdef __UNICODE
#define CreateFile CreateFileW
#else
#define CreateFile CreateFileA
#endif

So, these are the advantages and disadvantages of using defines.
:)
In the future try to avoid using names for functions that resembles some of the system.

HTH, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top