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

header guards from different files might be the same? #78

Open
dirk-thomas opened this issue Oct 14, 2015 · 2 comments
Open

header guards from different files might be the same? #78

dirk-thomas opened this issue Oct 14, 2015 · 2 comments
Labels

Comments

@dirk-thomas
Copy link
Contributor

cpplint uses a specific pattern for the header guards of a file. It looks to me that this pattern can lead to the same PP variable for different headers (with different names and paths).

Let me describe a simple scenario with two files:

  • include/foo_bar/baz.h
  • include/foo/bar_baz.h

Following cpplint rules both of them would end up using the header guard variable FOO_BAR_BAZ_H_.

Am I missing something or is this really the case? If it is, wouldn't it be better to change the rule to make these two result in different variables? E.g. a path separator could be transformed into a double underscore which would result in two different variables:

  • FOO_BAR__BAZ_H_
  • FOO__BAR_BAZ_H_
@chen3feng
Copy link

Then, how about:
foo__bar.h
foo/bar.h

@dirk-thomas
Copy link
Contributor Author

There are only two options:

Since I don't see which character would be allowed in a preprocessor name which isn't in a filename I suggested a double underscore. But any sequence would be subject to a potential collision if it is allowed in a filename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants