Skip to content

Commit

Permalink
rosconsole: don't use 0 as null pointer in macros (ros#1730)
Browse files Browse the repository at this point in the history
But use `NULL`, which will evaluate to `nullptr` on platforms where appropriate and `0` elsewhere.

Identical to ros/rosconsole#14.
  • Loading branch information
gavanderhoorn authored and dirk-thomas committed Oct 3, 2019
1 parent 194c776 commit a4cd1fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/rosconsole/include/ros/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ ROSCONSOLE_DECL std::string formatToString(const char* fmt, ...);

#define ROSCONSOLE_DEFINE_LOCATION(cond, level, name) \
ROSCONSOLE_AUTOINIT; \
static ::ros::console::LogLocation __rosconsole_define_location__loc = {false, false, ::ros::console::levels::Count, 0}; /* Initialized at compile-time */ \
static ::ros::console::LogLocation __rosconsole_define_location__loc = {false, false, ::ros::console::levels::Count, NULL}; /* Initialized at compile-time */ \
if (ROS_UNLIKELY(!__rosconsole_define_location__loc.initialized_)) \
{ \
initializeLogLocation(&__rosconsole_define_location__loc, name, level); \
Expand All @@ -346,7 +346,7 @@ ROSCONSOLE_DECL std::string formatToString(const char* fmt, ...);
::ros::console::print(filter, __rosconsole_define_location__loc.logger_, __rosconsole_define_location__loc.level_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__)

#define ROSCONSOLE_PRINT_AT_LOCATION(...) \
ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(0, __VA_ARGS__)
ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(NULL, __VA_ARGS__)

// inside a macro which uses args use only well namespaced variable names in order to not overlay variables coming in via args
#define ROSCONSOLE_PRINT_STREAM_AT_LOCATION_WITH_FILTER(filter, args) \
Expand All @@ -358,7 +358,7 @@ ROSCONSOLE_DECL std::string formatToString(const char* fmt, ...);
} while (0)

#define ROSCONSOLE_PRINT_STREAM_AT_LOCATION(args) \
ROSCONSOLE_PRINT_STREAM_AT_LOCATION_WITH_FILTER(0, args)
ROSCONSOLE_PRINT_STREAM_AT_LOCATION_WITH_FILTER(NULL, args)

/**
* \brief Log to a given named logger at a given verbosity level, only if a given condition has been met, with printf-style formatting
Expand Down

0 comments on commit a4cd1fa

Please sign in to comment.