Is header-only {fmt} safe from violations of One Definition Rule?

92 views Asked by At

Scenario:

Shared library uses {fmt} in header-only mode.

An application uses the library, and uses {fmt} in embedded non-header mode, i.e. the file format.cc is compiled and linked into the binary.

The library and the application don't necessarily use the same version of {fmt} (could f.ex. be 10.0.0 vs 10.1.0).


Is there a danger of violating the One Definition Rule here? Will {fmt} symbols in library leak into application/be visible when linking application?

If yes, is the problem:

  • mixing header-only and embedded?
  • mixing versions?
  • both?
1

There are 1 answers

0
Aykhan Hagverdili On BEST ANSWER

Is there a danger of violating the One Definition Rule here?

It might, yes.

Will {fmt} symbols in library leak into application/be visible when linking application?

Depends on how careful your library is. Your library should probably not export and hide those symbols. How to do that is going to depend on your compiler/OS.

both?

Yes, both. But if your library is careful to not export those symbols, you should generally be fine.