LoginSignup
4
4

expected unqualified-id, 11 articles、C++ Error(11) Message Collection(2)

Last updated at Posted at 2018-05-20

目的(purpose)

C++に限らず、コンパイルエラーがたくさん出るとめげる。
根本原因のエラーと、それに付属する関連エラーがあり、
根本原因エラーさえ取れば、みんなきれさっぱりなくなることがある。

複数のファイルにまたがるエラーは、相互に影響があり、どちらを直すとより効率的かを判断できないと無駄な作業が発生するかもしれない。

効率的にコンパイルエラーを取る方法を探るため、コンパイルエラー情報とその際の対応方法を収集する。

成果(outcome)

コンパイルエラーとその時の条件に従い、すぐにコンパイルエラーが取れるようになる。

コンパイルエラーが取れれば、printf(cout)デバッグができるかもしれない。

#関連(additional information)

悲しいのはprintf(cout)デバッグをしようとすると、コンパイルエラーが出る時。

printf(cout)デバッグをしてもコンパイルエラーが出ない方法も順次追記する。

複雑な構造を持った新たなclassは、直接coutしようとせず、よく知った必要な型に変換して出力するのも手かも。

castしようとすると、castのコンパイルエラーが出るかもしれない。
castでコンパイルエラーが出ない方法を知っているとよい。

#(2)expected unqualified-id

##2.1 error: expected unqualified-id before ‘delete’
C++で発生した「expected unqualified-id before ...」というエラーについて
https://teratail.com/questions/59258

原因:予約語の関数を再宣言・再定義していた。
解決:予約語以外に変更した。

##2.2 error: expected unqualified-id before ‘{’ token
expected unqualified-id before ‘{’ tokenをどうしたら良いかわからない
https://dixq.net/forum/viewtopic.php?t=8060

原因:関数定義でないのに{}の中に「return 0;」がある。
解決:関数定義でないところの「return 0;」を削る。

##2.3 expected unqualified-id before 'using'
Happy My Life 日常とか技術とか id:checkela はてなブログPro
http://blog.cnu.jp/blog/2008/11/17/expected-unqualified-id-before-using/

原因:「usingの前で宣言していたClassの最後に「;」が無い」
解決:Classの最後に「;」を追記。

####同一・類似事例(case study)
seToの日記
http://d.hatena.ne.jp/seTo/20100626/1277553152

##2.4 expected unqualified-id before numeric constant
下手の考え休むに似たり boulevard
http://d.hatena.ne.jp/boulevard/20110621

原因:同じ変数を定数とfloatで宣言していた。
解決:一方の名前を変更。

####同一・類似事例(case study)
aruduino のエラーがなおらなくて困っています
https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1479434869

スコット・マイヤーズ : Effective C++ C++ 50 の急所 MARUYAMA Satosi
http://www.ne.jp/asahi/music/marinkyo/libroj/efika-cpp.html.ja

2.5 expected unqualified-id before numeric constant

Arduinoで"error: expected unqualified-id before numeric constant"が2個出たら、原因は後の方にある id:shuzo_kino
http://shuzo-kino.hateblo.jp/entry/2016/04/16/145747

原因:「関数と関数の間に「888」とか謎の文字列」
解決:謎の文字列を「消す」

2.6 error: expected unqualified-id before '(' token

もの忘れの激しい自分へ
http://akiracraftwork.seesaa.net/article/125958348.html

原因:includeしたファイルで矛盾が発生。
解決:「#define NOMINMAX」を宣言

2.7 error: expected unqualified-id before ‘for’

ねぎもちもち
http://negimochix2.blogspot.jp/2008/07/error-expected-unqualified-id-before.html

原因:{}の位置(数)がおかしかった
解決:{}の位置、数を調整。

2.8 error: expected unqualified-id @class NSString, Protocol;

【iOS】Xcodeでビルドした時にNSObjCRuntimeでエラー?【cocos2d-x】
https://qiita.com/kuuki_yomenaio/items/6edc7cb16a81d2bc9ef5

原因:Objective C++のコードが混じっていた。
解決:

  1. ファイル拡張子を「.mm」に変更する
  2. Typeを「Objective-C++ Source」に変更する

2.9 error: expected unqualified-id

C++N3242, 2011 (32) 5.2.8 Type identification
https://researchmap.jp/jopwqe2hv-1797580/

原因:関数の中に記述すべき項目を関数の外に記載していた。
解決:関数の定義の中に移動。

####同一・類似事例(case study)
C++N4741(49)8.5.1.8 Type identification [expr.typeid]p104
https://qiita.com/kaizen_nagoya/items/d58bc3960065ade23581

2.10 error : expected unqualified-id

st1, lst2という名前はWindows.hのinclude によって、マクロ汚染される #82 yumetodo
https://github.com/bolero-MURAKAMI/Sprout/issues/82

原因:マクロで使っている名前がdefineで悪さする。
解決:#undef

2.11 error : expected unqualified-id

C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standard(61) 6.6.3 The return statement [stmt.return] p149
https://qiita.com/kaizen_nagoya/items/09918f1f62f3ed8e308a

原因:文字列""の途中で改行が入っていた。
解決:改行を削った。

#参考文献(reference)
C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
https://qiita.com/kaizen_nagoya/items/3294c014044550896010

C++N4606, 2016Working Draft 2016, ISO/IEC 14882,符号断片編纂一覧(example code compile list)
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/

C++N3242, 2011 sample code compile list on clang++ and g++
https://qiita.com/kaizen_nagoya/items/685b5c1a2c17c1bf1318

C++ Error Message Collection(1)does not name a type, 11 articles
https://qiita.com/drafts/acb9f1a9b5aad6df06bd

Reference

Error一覧 error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
This article is an individual impression based on the individual's experience. It has nothing to do with the organization or business to which I currently belong.

文書履歴(document history)

ver. 0.10 初稿 20180520
ver. 0.11 原因と解決を分けて記述 20180521
ver. 0.12 No.11「""の途中で改行」追記 20180522
ver. 0.13 みだし補正 20210509

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4