roboticslab-uc3m / color-debug

Colorful command line output C/C++ macros, very flexible!
http://robots.uc3m.es/gitbook-developer-manual/appendix/repository-index.html
GNU Lesser General Public License v2.1
6 stars 1 forks source link

Syntax error on braceless if-else statements #13

Closed PeterBowman closed 6 years ago

PeterBowman commented 6 years ago

The following code breaks:

#include <ColorDebug.h>

int main(void)
{
    if (0)
        CD_INFO("if\n");
    else
        CD_INFO("else\n");

    return 0;
}

Turns out we are misusing all do-whiles: they should encompass the macro from start to end AND lack a trailing semicolon. See:

PeterBowman commented 5 years ago

Prior to this fix, no semicolon was needed after each instruction containing a CD macro (which I find rather counterintuitive and dangerous), see https://github.com/asrob-uc3m/robotDevastation/commit/962829a45c787435b12e1030e07c277c9cf344f9.

jgvictores commented 5 years ago

Oh yes, I agree requiring a semicolon is definitely better!

jgvictores commented 5 years ago

Thank you!!!!!