ea4k / klog

KLog is a multiplatform free hamradio logger. It runs natively on Linux, macOS and Windows.
https://www.klog.xyz
GNU General Public License v3.0
75 stars 25 forks source link

Use a good discriminator in header guards #624

Closed ikbenkous closed 3 months ago

ikbenkous commented 1 year ago

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

ea4k commented 1 year ago

I was not aware of it. Very good catch. Thank you!