Skip to content

Remove using-directives from common headers - #3324

Merged
ktf merged 23 commits into
AliceO2Group:masterfrom
vkucera:namespace
Aug 17, 2023
Merged

ktf merged 23 commits into
AliceO2Group:masterfrom
vkucera:namespace

Conversation

@vkucera

@vkucera vkucera commented Aug 15, 2023

Copy link
Copy Markdown
Collaborator

Using-directives should never appear in headers because they irreversibly pollute the global namespace wherever they are included and can lead to unexpected behaviour, such as name conflicts. See O2 CodingGuidelines.

In fact, the evsel namespace was indeed defined ambiguously, once as o2::aod::evsel in EventSelection.h and another time as just evsel in EventSelectionParams.h. Maybe @ekryshen can comment whether this was intentional or not.

@ddobrigk I think we should have a CI check that forbids using namespace in header files. That would require fixing remaining occurrences in the PWG directories (which I did not do in this PR).

@vkucera
vkucera requested a review from ddobrigk August 15, 2023 14:30
@vkucera

vkucera commented Aug 15, 2023

Copy link
Copy Markdown
Collaborator Author

Sorry, there were a few fixes needed. It should be ready for merging now.

aalkin
aalkin previously approved these changes Aug 15, 2023
njacazio
njacazio previously approved these changes Aug 15, 2023
@aalkin

aalkin commented Aug 15, 2023

Copy link
Copy Markdown
Member

Regarding evsel and aod::evsel, I would prefer them separate. Namespace aod is reserved for columns and tables. Probably the functional namespace can be something like evsel_impl or evsel_detail, since it is supposed to be distinct from aod::evsel which contains column definitions.

@vkucera

vkucera commented Aug 15, 2023

Copy link
Copy Markdown
Collaborator Author

Hi @aalkin , ok. Are you fine with renaming in a separate PR?

saganatt
saganatt previously approved these changes Aug 15, 2023
fcatalan92
fcatalan92 previously approved these changes Aug 15, 2023
@aalkin

aalkin commented Aug 15, 2023

Copy link
Copy Markdown
Member

@vkucera yes, of course, let's not waste the approvals :)

@vkucera

vkucera commented Aug 16, 2023

Copy link
Copy Markdown
Collaborator Author

@ddobrigk @TimoWilken Is it fine for you to merge this without waiting for the remaining approvals?

ekryshen
ekryshen previously approved these changes Aug 16, 2023
@ddobrigk

Copy link
Copy Markdown
Collaborator

To avoid any conflicts, maybe we can manual-force-merge? @ktf or @pzhristov maybe? Thanks a lot!

@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/o2 for 9805abf at 2023-08-16 17:53:

## sw/BUILD/O2Physics-latest/log
[ERROR] Function RecoDecay::getMassPDG is deprecated and will be removed soon.
[ERROR] Please use the Mass function in the O2DatabasePDG service instead.
[ERROR] See the example of usage in Tutorials/src/usingPDGService.cxx.
[ERROR] Function RecoDecay::getMassPDG is deprecated and will be removed soon.
[ERROR] Please use the Mass function in the O2DatabasePDG service instead.
[ERROR] See the example of usage in Tutorials/src/usingPDGService.cxx.
[ERROR] Function RecoDecay::getMassPDG is deprecated and will be removed soon.
[ERROR] Please use the Mass function in the O2DatabasePDG service instead.
[ERROR] See the example of usage in Tutorials/src/usingPDGService.cxx.
[ERROR] Function RecoDecay::getMassPDG is deprecated and will be removed soon.
[ERROR] Please use the Mass function in the O2DatabasePDG service instead.
[ERROR] See the example of usage in Tutorials/src/usingPDGService.cxx.
[ERROR] Function RecoDecay::getMassPDG is deprecated and will be removed soon.
[ERROR] Please use the Mass function in the O2DatabasePDG service instead.
[ERROR] See the example of usage in Tutorials/src/usingPDGService.cxx.
[ERROR] Function RecoDecay::getMassPDG is deprecated and will be removed soon.
[ERROR] Please use the Mass function in the O2DatabasePDG service instead.
[ERROR] See the example of usage in Tutorials/src/usingPDGService.cxx.
[ERROR] Function RecoDecay::getMassPDG is deprecated and will be removed soon.
[ERROR] Please use the Mass function in the O2DatabasePDG service instead.
[ERROR] See the example of usage in Tutorials/src/usingPDGService.cxx.
/sw/SOURCES/O2Physics/3324-slc7_x86-64/0/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx:358:24: error: 'array' was not declared in this scope; did you mean 'std::array'?
ninja: build stopped: subcommand failed.

Full log here.

@vkucera
vkucera dismissed stale reviews from ekryshen, fcatalan92, saganatt, njacazio, and aalkin via b6b7e6d August 16, 2023 19:31
@ktf
ktf merged commit e74535c into AliceO2Group:master Aug 17, 2023
@ktf

ktf commented Aug 17, 2023

Copy link
Copy Markdown
Member

Merged this now. I have noticed two other quite bad practices, while reviewing this:

  • For no reason one should have #include <iostream> in headers, as it bloats every single file which includes it with statics.
  • In general there should not be any reason for having statics in the header files.

@vkucera
vkucera deleted the namespace branch August 17, 2023 08:22
hahassan7 pushed a commit to hahassan7/O2Physics that referenced this pull request Oct 6, 2023
hahassan7 pushed a commit to hahassan7/O2Physics that referenced this pull request Oct 7, 2023
samrangy pushed a commit to samrangy/O2Physics that referenced this pull request Oct 11, 2023
zconesa pushed a commit to zconesa/O2Physics that referenced this pull request Oct 27, 2023
chengtt0406 pushed a commit to chengtt0406/O2Physics that referenced this pull request Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

10 participants