初級 › error: expected ',' or ';' before ... の原因と直し方 › パターン2
error: expected ',' or ';' before ... の原因と直し方
文末のセミコロンを書き忘れたときに出るエラーです。
1 #include <iostream> 2 int main() { 3 int total = 10 + 20_ ^ 4 std::cout << total << std::endl; 5 return 0; 6 }
main.cpp:4:5: error: expected ',' or ';' before 'std'
空欄を埋めてコンパイル・実行を通す
式の後にセミコロンが無いと、コンパイラは文がまだ続いていると判断し、次の行の先頭で行き詰まります。
次の問題