The glfw3-library can be made to include vulkan using a definition before the include:
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
i want to do a similar thing, but for debug vs non-debug-mode. I tried the following:
main.cpp:
#define DEBUG_ENABLED
#include "someFile.hpp"
someFile.hpp:
#ifdef DEBUG_ENABLED
std::vector<const char*> _debugExtensions = {
VK_EXT_DEBUG_UTILS_EXTENSION_NAME
};
#endif
#ifndef DEBUG_ENABLED
std::vector<const char*> _debugExtensions = {};
#endif
I checked if that 'passing of definitions' across the header-files worked, by printing the size of the vector, but received zero which indicates that the compiler didn't consider the DEBUG_ENABLED to be defined inside the someFile.hpp.
I then looked on stackoverflow to see how i could react to the definitions of an extern file, and found this post:
Is it possible to use #define from other cpp file?
The accepted answer there claims that
Defines inside a source file aren't seen by other translation units. Implementation files are compiled separately.
My problem with this answer is that my experience tells me the contrary, as the included glfw mentioned above clearly reacted to the GLFW_INCLUDE_VULKAN definition i made.
How might one be able to achieve such behaviour (being able to react to definitions made in an extern source-file) ?