clang的編譯器有點智慧

lt發表於2016-11-28
D:\>clang++ p88.cpp -O2
p88.cpp:21:14: error: use of undeclared identifier 'pank'; did you mean 'psnk'?
printf("%d ",pank[i]);
             ^~~~
             psnk
p88.cpp:3:5: note: 'psnk' declared here
int psnk[(MAXN + 5)] = {0};
    ^
1 error generated.

變數名寫錯都能提示可能的值

D:\>clang++ p582a.cpp -O2
p582a.cpp:34:19: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
    for (int t; t = x % y; x = y, y = t);
                ~~^~~~~~~
p582a.cpp:34:19: note: place parentheses around the assignment to silence this warning
    for (int t; t = x % y; x = y, y = t);
                  ^
                (        )
p582a.cpp:34:19: note: use '==' to turn this assignment into an equality comparison
    for (int t; t = x % y; x = y, y = t);
                  ^
                  ==

對於用賦值結果作條件的,提醒可能漏寫了一個=

相關文章