diff --git a/gtsam/inference/Key.cpp b/gtsam/inference/Key.cpp index 8fcea0d05..15d633eeb 100644 --- a/gtsam/inference/Key.cpp +++ b/gtsam/inference/Key.cpp @@ -10,7 +10,7 @@ * -------------------------------------------------------------------------- */ /** - * @file Key.h + * @file Key.cpp * @brief * @author Richard Roberts * @author Alex Cunningham @@ -26,6 +26,9 @@ using namespace std; namespace gtsam { +/// Assign default key formatter +KeyFormatter DefaultKeyFormatter = &_defaultKeyFormatter; + /* ************************************************************************* */ string _defaultKeyFormatter(Key key) { const Symbol asSymbol(key); diff --git a/gtsam/inference/Key.h b/gtsam/inference/Key.h index 31428a50e..a02d018f5 100644 --- a/gtsam/inference/Key.h +++ b/gtsam/inference/Key.h @@ -37,10 +37,16 @@ using KeyFormatter = std::function; // Helper function for DefaultKeyFormatter GTSAM_EXPORT std::string _defaultKeyFormatter(Key key); -/// The default KeyFormatter, which is used if no KeyFormatter is passed to -/// a nonlinear 'print' function. Automatically detects plain integer keys -/// and Symbol keys. -static const KeyFormatter DefaultKeyFormatter = &_defaultKeyFormatter; +/** + * The default KeyFormatter, which is used if no KeyFormatter is passed + * to a 'print' function. + * + * Automatically detects plain integer keys and Symbol keys. + * + * Marked as `extern` so that it can be updated by external libraries. + * + */ +extern GTSAM_EXPORT KeyFormatter DefaultKeyFormatter; // Helper function for Multi-robot Key Formatter GTSAM_EXPORT std::string _multirobotKeyFormatter(gtsam::Key key); @@ -124,7 +130,3 @@ struct traits { }; } // namespace gtsam - - - -