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

ROS_ASSERT is not working #1163

Closed
littlejohnyang opened this issue Sep 13, 2017 · 1 comment
Closed

ROS_ASSERT is not working #1163

littlejohnyang opened this issue Sep 13, 2017 · 1 comment
Labels

Comments

@littlejohnyang
Copy link

littlejohnyang commented Sep 13, 2017

I'm running Ubuntu 14.02 x64 and ROS Jade. I'm running into a weird issue with ROS_ASSERT. It compiles fine but it is not functioning as expected. I have following code and I realised it's not even executing the function SerialNumberFromHex():

    std::string serial_number_str;
    if(!config_nh_.getParam("serial_number", serial_number_str))
    {
        ROS_ERROR("You must specify a serial number");
        valid_ = false;
    }
    else
    {
        ROS_ASSERT( SerialNumberFromHex(serial_number_str, &serial_number_) );
        ROS_INFO_STREAM("serial number="<<serial_number_str<<" ,hex-> "<<serial_number_);
    }

Then I tried directly:

ROS_ASSERT(false);

, and surprisingly it is not throwing any error.

And exactly the same code works fine on another machine running Ubuntu 14.04 x64 without any issue (and ROS_ASSERT(false) will throw error as expected). The same code was definitely working before on the PC but not any more now. Because compilation has no issue (I rerun cmake and recompile everything including removing the lib files manually), any possible cause to this? (e.g. compiler issue, etc?)

@dirk-thomas
Copy link
Member

ROS_ASSERT has the same semantic as the macro assert(). When NDEBUG is defined (which is the case for all non-debug builds) the macro is being disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants