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

Compiling error caused by the LOG_IF definition since glog 0.4.0 #1141

Open
tjliupeng opened this issue Nov 20, 2024 · 1 comment
Open

Compiling error caused by the LOG_IF definition since glog 0.4.0 #1141

tjliupeng opened this issue Nov 20, 2024 · 1 comment

Comments

@tjliupeng
Copy link

tjliupeng commented Nov 20, 2024

Since glog 0.4.0, the LOG_IF Macro is defined as follow:
#define LOG_IF(severity, condition) static_cast<void>(0), !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
static_cast<void>(0) is added. This change is from the commit Protect macros from user code to the left of them. I understand that case.

In our code, we have macros defined as follow:

#define RECORD_DATA_NORMAL_MACRO(type_name, data_type, logger, timestamp, ...)
do {
......
logger << "Timestamp: " << timestamp << ", time consuming: " << duration.count() / 1000 << " ms";
} while (0)

#define RECORD_OD_DATA(res, t_res, param, timestamp, logger)
RECORD_DATA_NORMAL_MACRO("Od", Tools::ImageBevOdData, logger, timestamp, res, t_res, param, timestamp)

The macro is used below:
RECORD_OD_DATA(d_res, t_res, param_list, perc_msg->time_stamp_, VLOG(0));

You can see that VLOG(0) is a macro argument. When the macro is expanded, we get compiling error because static_cast<void>(0) exists. If we remove it, the error is gone.

Thanks!

@sergiud
Copy link
Collaborator

sergiud commented Nov 29, 2024

I don't see how this is a glog issue. The problem is clearly caused by the way you use VLOG. You cannot expect glog macros to defined in a certain way. Rather, your implementation must be able to deal with the provided definition.

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