I am working on a open source project (Blender) and have encountered the problem that many source code files like the file I am currently working on don't have the necessary header files #included
. For example in the example file class float3
and class KernelGlobals
do not have a definition anywhere in the file.
As Blender is an open source project I have all the source code that's needed. The IDE I'm using is Visual Studio 2022 Community Edition and I'm compiling with the compiler set to the C++17 standard.
What's worse is that there usually are multiple source code files defining the same identifier. For example Visual Studio shows 6 files defining class KernelGlobals
.
When I then compile the code the Visual C++ compiler gives my an error for every class that doesn't have a definition, yet the whole build still somehow succeds.
I want to stress that I did not modify the files in any way. Everything is exactly the source code for the official Blender build.
- How does the build succed, even though it gives hundreds of errors due to missing definition?
- How does Visual C++ know which definition to use when there are multiple definitions available, as is the case with e.g.
KernelGlobals
? - Is this behavior even described by the ISO C++ standard or is it just a Visual Studio thing?
The ouput from a succesful build is:
Build started...
1>------ Build started: Project: cycles_osl_shaders, Configuration: Release x64 ------
2>------ Build started: Project: cycles_kernel_osl, Configuration: Release x64 ------
3>------ Skipped Build: Project: RUN_TESTS, Configuration: Release x64 ------
3>Project not selected to build for this solution configuration
4>------ Build started: Project: locales, Configuration: Release x64 ------
2>services.cpp
2>cycles_kernel_osl.vcxproj -> C:build_windows_x64_vc17_Release\lib\Release\cycles_kernel_osl.lib
5>------ Build started: Project: cycles_kernel, Configuration: Release x64 ------
5>kernel.cpp
5>cycles_kernel.vcxproj -> C:build_windows_x64_vc17_Release\lib\Release\cycles_kernel.lib
6>------ Build started: Project: blender, Configuration: Release x64 ------
6> Creating library C:build_windows_x64_vc17_Release/bin/Release/blender.lib and object C:build_windows_x64_vc17_Release/bin/Release/blender.exp
6>blender.vcxproj -> C:build_windows_x64_vc17_Release\bin\Release\blender.exe
7>------ Skipped Build: Project: PACKAGE, Configuration: Release x64 ------
7>Project not selected to build for this solution configuration
8>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
8>Project not selected to build for this solution configuration
========== Build: 5 succeeded, 0 failed, 156 up-to-date, 3 skipped ==========