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

Don't define member functions inside a nested namespace #113

Closed

Conversation

mortbopet
Copy link
Contributor

This trips up MSVC, in that member functions aren't properly included in the object files of the various translation units.

e.g. DumpBin of symbol_table.lib:
image

Generally, this can be fixed by having a using declaration in a .cpp file to enable the namespace. From my experience, a general good practice is to never nest definitions in namespaces, unless the namespace is only visible from within a translation unit (e.g. a detail namespace inside a .cpp file).

This doesn't fix all of the places in the code where this pattern is used - only the (narrow) compile path that i've been excercising. Someone should probably go through the rest of the codebase and apply this - will be needed if/when a windows CI pipeline is added.

This trips up MSVC, in that member functions aren't properly included in the object files of the various translation units. Generally, this should be fixed by having a `using` declaration in a .cpp file. From my experience, a general good practice is to never nest definitions in namespaces, unless that is only visible from within a translation unit (e.g. a `detail` namespace inside a .cpp file).

This doesn't fix all of the places in the code where this pattern is used - only the (narrow) compile path that i've been excercising. Someone should probably go through the rest of the codebase and apply this - will be needed if/when a windows CI pipeline is added.
@@ -12,7 +12,7 @@
#include "substrait/textplan/Location.h"
#include "substrait/textplan/StructuredSymbolData.h"

namespace io::substrait::textplan {
Copy link
Member

Choose a reason for hiding this comment

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

Would changing this to three separate namespace definitions did the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's hard to find documentation about this (it's sort of a bug-in-limbo...). I'm not at my workstation at the moment so i can't give an answer now, but my hunch would be no.

@mortbopet mortbopet closed this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants