Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a good discriminator in header guards #624

Closed
ikbenkous opened this issue Sep 17, 2023 · 1 comment
Closed

Use a good discriminator in header guards #624

ikbenkous opened this issue Sep 17, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@ikbenkous
Copy link
Contributor

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 ea4k added enhancement New feature or request good first issue Good for newcomers labels Sep 23, 2023
@ea4k ea4k added this to the KLog-2.4 milestone Sep 23, 2023
@ea4k
Copy link
Owner

ea4k commented Sep 23, 2023

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

@ikbenkous ikbenkous changed the title Use a good discriminator in include guards Use a good discriminator in header guards Nov 25, 2023
ea4k added a commit that referenced this issue Dec 12, 2023
@ea4k ea4k closed this as completed Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants