Skip to content

Commit

Permalink
fix __VA_ARGS__ issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed Feb 27, 2024
1 parent ab0d620 commit df90a34
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/include/bofstd/bofconio.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <bofstd/bofpath.h>

BEGIN_BOF_NAMESPACE()
#define PrintfAt(x, y, pFormat, ...) PrintfAtColor(mForeColor_E, x, y, pFormat, __VA_ARGS__)
#define PrintfColor(Color, pFormat, ...) PrintfAtColor(Color, 0, 0, pFormat, __VA_ARGS__)
#define PrintfAt(x, y, pFormat, ...) PrintfAtColor(mForeColor_E, x, y, pFormat, ##__VA_ARGS__)
#define PrintfColor(Color, pFormat, ...) PrintfAtColor(Color, 0, 0, pFormat, ##__VA_ARGS__)

enum CONIO_MODIFIER_KEY_FLAG : uint32_t
{
Expand Down
4 changes: 2 additions & 2 deletions lib/include/bofstd/boflogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const uint32_t BOF_LOGGER_CHANNEL_FLAG_MASK_DBG_ALWAYS = 0x80000000; /*! Always
const uint32_t BOF_LOGGER_CHANNEL_FLAG_MASK_DBG_ERROR = 0x40000000; /*! Display error */
const uint32_t BOF_LOGGER_MAX_FAST_FORMAT_BUFFER_SIZE = 0x8000;
#if defined(_WIN32)
#define BOF_LOG_TO_DBG(pFormat,...) {std::string Dbg;BOF::Bof_Sprintf(pFormat, __VA_ARGS__);OutputDebugString(Dbg.c_str());}
#define BOF_LOG_TO_DBG(pFormat,...) {std::string Dbg;BOF::Bof_Sprintf(pFormat, ##__VA_ARGS__);OutputDebugString(Dbg.c_str());}
#else
#define BOF_LOG_TO_DBG(pFormat,...) {printf(pFormat, __VA_ARGS__);}
#define BOF_LOG_TO_DBG(pFormat,...) {printf(pFormat, ##__VA_ARGS__);}
#endif
// #define BOF_LOGGER_DEBUG_ON // To avoid extra cost when we want no log and no fct call at all
// The ##__VA_ARGS__ syntax is non-standard. It is a "swallow comma if the __VA_ARGS__ is empty" extension implemented by GCC, and seems to have been adopted by other compilers.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bofsocketthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BEGIN_BOF_NAMESPACE()
constexpr uint32_t PUSH_POP_TIMEOUT = 150; // Global To for getting command out of incoming queue, in ListeningMode_B it is half of the To specified for listen
constexpr uint32_t DEF_IO_TIMEOUT = 2000;

#define SOCK_IO_DBG(pFormat,...) {printf("%d: " pFormat,Bof_GetMsTickCount(), __VA_ARGS__);}
#define SOCK_IO_DBG(pFormat,...) {printf("%d: " pFormat,Bof_GetMsTickCount(), ##__VA_ARGS__);}
#define SOCK_THREAD_PROGRAM_OPERATION(Field, Operation) \
BOFERR Rts_E; \
BOF_SOCKET_OPERATION_PARAM Param_X; \
Expand Down
4 changes: 2 additions & 2 deletions tests/src/ut_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ void MyExternalSingleChannelLibCode(std::shared_ptr<BOF::IBofLoggerFactory> _psL
EXPECT_EQ(NbLogRejected_U32, 1);
}
/*
#define WLOG(channel, ...) BOF_LOG_WARNING(MY_LOGGER, channel, __VA_ARGS__);
#define WLOG(channel, ...) BOF_LOG_WARNING(MY_LOGGER, channel, ##__VA_ARGS__);
#define MY_LOGGER TheBhaLogger
BOF_LOGGER_DEFINE_STORAGE(MY_LOGGER, LOGGER_CHANNEL_MAX);
*/
constexpr uint32_t MAX_MULTI_CHANNEL = 3;
#define WLOG(channel, ...) BOF_LOG_WARNING(MY_UT_LOGGER, channel, __VA_ARGS__);
#define WLOG(channel, ...) BOF_LOG_WARNING(MY_UT_LOGGER, channel, ##__VA_ARGS__);
#define MY_UT_LOGGER TheUtLogger
BOF_LOGGER_DEFINE_STORAGE(MyExternalMultipleChannelLibLogger, MAX_MULTI_CHANNEL);
void MyExternalMultipleChannelLibInit(std::shared_ptr<BOF::IBofLoggerFactory> _psLoggerFactory)
Expand Down

0 comments on commit df90a34

Please sign in to comment.