Odd issue in Visual Studio 2019 & 2022 project with a file named Process.h

Started by
2 comments, last by HardlineStudios 1 year, 2 months ago

Hey all, ok so TLDR; It seems for some reason, using a local Process.h file in my project with newer versions of Visual Studio breaks compilation. Hopefully this post helps someone not waste a day figuring out why as I'm sure there are a few DIY engines out there with a process.h file! ?

Alright so in my game engine, I have a pre-compiled header (pch.h) which is compiled via pch.cpp as per the norm. Within pch.h, I have all the includes for the whole engine including a file called Process.h which has a class called CProcess (for... processing things).

Up until Visual Studio 2017 (using Platform Toolset v141) the pch would compile fine as would the whole engine. I just recently updated the project to VS 2022 and now when it starts compiling the pch file, it breaks with loads of errors when it gets to the Process.h. The errors make it seem almost like Process.h wasn't part of the project as within Process.h, project wide defines or data types aren't being detected hence all the errors. I noticed the Windows Platform SDK has a file called Process.h which seems to be part of the problem. Trying different versions of the Windows Platform SDK didn't make a difference.

My Process.h file is included with quotes (#include "Process.h") and didn't make a difference using angle brackets. If I switched the Platform Toolset back to v141 (VS 2017) things compile normally so this only seems to happen with later versions (both VS 2019 and 2022). The only way around this was to change the name of Process.h to Task.h and it started working again. Even leaving the class name as is (CProcess). So yeah. Oddballz.

Anyone have any idea why this happens?

None

Advertisement

HardlineStudios said:
I noticed the Windows Platform SDK has a file called Process.h which seems to be part of the problem.

Maybe it would help to put your source files into some sub directory.
Then, if you would include it using e.g. #include"Core/Process.h", i assume such confusion can't happen.

Basically it's the same idea as using namespaces to keep duplicate names distinguishable. Sub directories for the file system, namespaces for the code itself.

HardlineStudios said:
Anyone have any idea why this happens?

If you do just #include"Process.h", the compiler coincidentally finds the platform SDK file first, and then it won't look elsewhere just because there are errors.

Well interestingly enough I just setup a new test project with minimal files and a process.h file and… nothing happens. Must be some odd ball thing in my project files which admittedly were created in back in VS 2015 and then evolved through 2017 and now 2019.

I guess I confused the compiler to not look for Process.h in my project first but in the end, I just renamed it to Task.h and the problem went away. Just an oddity I guess.

None

This topic is closed to new replies.

Advertisement