Closed abhishekmishra closed 2 years ago
Hi, Abhishek! I'm glad you like it.
Hmm, that's strange. Are you building from the command-line or from the IDE? If you are using the IDE, did you select the CMakeLists.txt
file when opening the project so that Visual Studio recognizes this as a CMake project? Note that the CMake files in this project specify some custom compilation settings which may be required for the program to compile with MSVC.
Cheers.
Hi magiblot, thanks for your response. To answer your question yes I ran the build from the command prompt (via cmake) as well as from visual studio. I tried building your app turbo and it built fine with VS, then I went back and started commenting out code in my program. I was using a few C libraries, as soon as I removed them, the compilation errors for util.h went away. Turns out inclusion of c language headers is causing an error in this particular build. I'm still trying to figure out why... Once i've figured it out I will update this thread.
thanks again.
quick update - finally got the build working by moving turbovision includes above all the others. And then the build works fine without errors on vs2022.
Now that you say that, I think I can guess what was going on. Among those other headers you were including there probably was, directly or indirectly, windows.h
. When windows.h
is included and the NOMINMAX
macro is not defined, then it defines the min()
and max()
macros, which result in compilation errors if you later define functions of the same name. This is exactly the case of the tvision/util.h
header where the compilation error happened. Therefore, you should also be able to solve this issue by defining the NOMINMAX
macro in your CMake target.
Now that you say that, I think I can guess what was going on. Among those other headers you were including there probably was, directly or indirectly,
windows.h
. Whenwindows.h
is included and theNOMINMAX
macro is not defined, then it defines themin()
andmax()
macros, which result in compilation errors if you later define functions of the same name. This is exactly the case of thetvision/util.h
header where the compilation error happened. Therefore, you should also be able to solve this issue by defining theNOMINMAX
macro in your CMake target.
thanks this makes sense, i'll give it a shot and let you know.
hi magiblot, can confirm that defining this macro fixes the issue on msvc builds. thanks a lot for helping me fix this. here's the entry in my CMakeLists.txt
# see issue https://github.com/magiblot/tvision/issues/67#issuecomment-1038207921
# stop windows.h from definiing min and max
if (WIN32)
add_compile_definitions(NOMINMAX)
endif (WIN32)
First of all, thanks for the excellent library. I've been building a tiny program on linux and it works fine. I'm using tvision as a git submodule, and building using cmake.
However, when I use Visual Studio 2022 with the same code, I get the following errors when building the generated solution... Is there something obvious I'm missing?