klog
klog copied to clipboard
Use a good discriminator in header guards
Include guard name collisions are no fun to debug. The core cpp guidelines recommend a 'good discriminator'. https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf8-use-include-guards-for-all-header-files
Since paths are unique, I recommend the following syntax: KLOG_PATH_TO_FILE_H
#define ... |
path |
|---|---|
KLOG_DATABASE_H |
src/database.h |
KLOG_WIDGETS_MAP_MAPWIDGET_H |
"src/widgets/map/mapwidget.h" |
This way you won't have collisions of something like DATABASE_H between different projects or even inside of the project itself.
There could be multiple database.h files...
Let me know what you think. @ea4k
I was not aware of it. Very good catch. Thank you!