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

Support for 'user-defined' namespace #2642

Closed
jstrzebonski opened this issue Dec 10, 2021 · 1 comment
Closed

Support for 'user-defined' namespace #2642

jstrzebonski opened this issue Dec 10, 2021 · 1 comment

Comments

@jstrzebonski
Copy link

We're using fmt in a library https://github.com/DARMA-tasking/vt, which can be next linked to an app, that itself uses fmt for its own purposes. We'd like to protect ourselves from any kind of ODR violations or ABI mismatch problems, or anything alike. It seems that the simplest way would be to just use our own namespace inside of the fmt namespace.

At first I wanted to simply define FMT_BEGIN_NAMESPACE to something like

#define FMT_BEGIN_NAMESPACE \
  namespace fmt {           \
  FMT_INLINE_NAMESPACE vt {
#endif

but in core.h there's one place where fmt::<version> is explicitly used

void to_string_view(...);
using fmt::v8::to_string_view;

What I did in the end was adding another macro, and replacing explicit references to version, with that macro

#ifndef FMT_INLINE_NAMESPACE_NAME
#  define FMT_INLINE_NAMESPACE_NAME v7
#endif

Could something like this be added to fmt, to add possibility to easily define own namespace for fmt?

For reference, here's a PR to our library with described changes:
DARMA-tasking/vt#1618

@vitaut
Copy link
Contributor

vitaut commented Dec 10, 2021

I think v8 is no longer needed in

using fmt::v8::to_string_view;
because we require inline namespace support now. A PR to remove it would be welcome.

mkurdej added a commit to mkurdej/fmt that referenced this issue Dec 10, 2021
@vitaut vitaut closed this as completed in 3a951a6 Dec 10, 2021
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

No branches or pull requests

2 participants