Jump to content

#undef GetFileType


george68
 Share

Recommended Posts

I don't have standard edition so I could be wrong but in Windows API GetFileType(defined when windows.h is involved) is a macro for GetFileTypeA() or GetFileTypeW() which is a problem because the Leadwerks API unfortunately uses the same function name for FileSystem::GetFileType(). The C++ preprocessor would dump GetFileTypeA or GetFileTypeW anywhere you have the text GetFileType. So FileSystem::GetFileType() would become FileSystem::GetFileTypeA() (or FileSystem::GetFileTypeW()) and cause a compile time error. By saying #undef GetFileType you are telling the preprocessor not to do the awkward mess above.

  • Upvote 1
Link to comment
Share on other sites

It sounds logical.

I am wondering why it is not included in the 'Leadwerks.h' file.

You could put it in Leadwerks.h but a header file that mucks with the defines and macros in Windows.h(and it's friends) without the programmer knowing will spread the undef to anything that includes Leadwerks.h which could lead to some undesired effects. It'd be frustrating to try to use GetFileType() exactly how MSDN says to then try to use it and the compiler says what the hell is GetFileType()? This kind of workaround should be isolated to the smallest area possible imo, perhaps even moved to a .cpp file.

 

At the end of the day this is a poor design choice by Microsoft and this is one of the weird things that occasionally come up in software on Windows. I think a better solution would have been to use a typedef rather than a define but it's far too late in the game for Microsoft to change it if it would even work with all the edge cases they have to meet.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...