Hello,
I'm looking for a way to generate an error code - message table based on strings in my code.
For example
void* poBlock = malloc(bytes);
if (poBlock == nullptr)
{
CRASH("Memory allocation failed");
}
Let's say I have two builds, a debug and a release.
If I use the debug build, I want to keep that string as is in the code, and display it when this error happens.
If I use the release build, I want to transform that string into a unique error code instead, and display it when this error happens.
CRASH is a macro and I can do that easily with a hash function.
However, what I don't know how to do is to generate list mapping the error code to the original string.
I would like to generate a custom file containing this information during the compilation of that build, but I'm not sure how to do so.
Could you direct me towards resources or show me how to achieve this ?
I'm using Visual Studio 2022 (17.13.2, v143) and C17
Thank you
(Please mention me)