Is there any flag in GCC (e.g. -Wempty-body in clang) that can help me define semicolons after while / for curly braces? Sometimes itβs very difficult for people to find these simple mistakes.
int i = 0; for (i = 0; i < 10; ++i); { cout << i << endl; }
I am using GCC 4.7.3 and clang 3.2-1 ~ exp9ubuntu1.
Edited: I also check to see if compilers can help me find these errors after the words "if-else".
if (i == 0) { cout << i << endl; } else; { cout << i << endl; }
Interestingly, gcc is more useful than clang (with these flags ( -Wall -pedantic -Wempty-body ), printing a warning:
main.cpp:30:9: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
source share