Code Fix

初級error: expected ',' or ';' before ... の原因と直し方 › パターン1

error: expected ',' or ';' before ... の原因と直し方

文末のセミコロンを書き忘れたときに出るエラーです。

 1  #include <iostream>
 2  int main() {
 3      int x = 5_
                 ^
 4      std::cout << x << std::endl;
 5      return 0;
 6  }
main.cpp:4:5: error: expected ',' or ';' before 'std'

空欄を埋めてコンパイル・実行を通す

広告
広告スロット(未設定)

error: expected ',' or ';' before ... の原因と直し方

エラーが指す行ではなく、その1つ前の行にセミコロンが無いことがほとんどです。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)