george68 Posted January 19, 2016 Share Posted January 19, 2016 The statement '#undef GetFileType' there is in the App.h file In what does it serve for? Quote Link to comment Share on other sites More sharing options...
thehankinator Posted January 19, 2016 Share Posted January 19, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
george68 Posted January 19, 2016 Author Share Posted January 19, 2016 It sounds logical. I am wondering why it is not included in the 'Leadwerks.h' file. Quote Link to comment Share on other sites More sharing options...
thehankinator Posted January 19, 2016 Share Posted January 19, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.