Skip to content

Conversation

StrikerRUS
Copy link
Collaborator

Refer to #7002.

I believe this linting rule is quite important because it helps to catch things like

include/LightGBM/cuda/cuda_rocm_interop.h:0:  No #ifndef header guard found, suggested CPP variable is: INCLUDE_LIGHTGBM_CUDA_CUDA_ROCM_INTEROP_H_  [build/header_guard] [5]

@StrikerRUS StrikerRUS marked this pull request as ready for review October 12, 2025 17:01
Comment on lines +5 to +6
#ifndef SRC_NETWORK_LINKERS_H_
#define SRC_NETWORK_LINKERS_H_
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line with the INCLUDE_ definitions, shouldn't this be

Suggested change
#ifndef SRC_NETWORK_LINKERS_H_
#define SRC_NETWORK_LINKERS_H_
#ifndef SRC_LIGHTGBM_NETWORK_LINKERS_H_
#define SRC_LIGHTGBM_NETWORK_LINKERS_H_

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpplint expects exactly these variables...
E.g.

...
src/treelearner/gpu_tree_learner.h:5:  #ifndef header guard has wrong style, please use: SRC_TREELEARNER_GPU_TREE_LEARNER_H_  [build/header_guard] [5]
src/treelearner/gpu_tree_learner.h:287:  #endif line should be "#endif  // SRC_TREELEARNER_GPU_TREE_LEARNER_H_"  [build/header_guard] [5]
...
include/LightGBM/utils/random.h:5:  #ifndef header guard has wrong style, please use: INCLUDE_LIGHTGBM_UTILS_RANDOM_H_  [build/header_guard] [5]
include/LightGBM/utils/random.h:117:  #endif line should be "#endif  // INCLUDE_LIGHTGBM_UTILS_RANDOM_H_"  [build/header_guard] [5]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for the explanation!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify this... cpplint is just translating the directory structure into these identifiers. This file is at src/network/, not src/LightGBM/network/.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait actually, before we merge... I thought about this more and realized that not having LIGHTGBM_ or similar in the name increases the risk of conflicts with definitions from other projects.

@StrikerRUS could you try the suggestion from cpplint/cpplint#44 (comment), to see if it'd result in cpplint being OK with everything prefixed with LIGHTGBM_?

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me! I just recently spent time typing out a review comment on a PR about this (#7039 (comment)), I'm happy to have a linter catch it automatically instead.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just thought about this and I'm worried that generic names like SRC_APPLICATION_PREDICTOR_HPP_ could risk conflicting with other projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants