提示コードですが以下のエラーが出るのですが「error: ‘Console::ListItem’ has not been declared」「Console::ListItemが定義されていません」とはどういう意味なのでしょうか?同じ名前空間のなので定義されているはずなのですが?
確認したこと
インクルードガードがそれぞれ違うかどうか確認
同じ名前空間かどうか確認
スペルミスを確認
知りたいこと
1,エラー原因が知りたいなぜ定義されてないなのか?
2,Console::ListItem
とListItem
は何が違うのか?
Error
shigurechan@shigurechan-System-Product-Name:~/Program/ScriptEditor$ make all make ext_lib make[1]: ディレクトリ '/home/shigurechan/Program/ScriptEditor' に入ります ar x /usr/lib/libncurses.a --output lib/obj make[1]: ディレクトリ '/home/shigurechan/Program/ScriptEditor' から出ます make make[1]: ディレクトリ '/home/shigurechan/Program/ScriptEditor' に入ります g++ -c -MMD -MP src/Main.cpp -o obj/Main.o In file included from src/../lib/src/Console.hpp:9, from src/MainScreen.hpp:6, from src/Main.cpp:2: src/../lib/src/MenuWindow.hpp:20:22: error: ‘Console::ListItem’ has not been declared 20 | void SetItem(Console::ListItem i); | ^~~~~~~ src/../lib/src/MenuWindow.hpp:33:30: error: ‘ListItem’ is not a member of ‘Console’ 33 | std::vector<Console::ListItem> item; | ^~~~~~~~ src/../lib/src/MenuWindow.hpp:33:38: error: template argument 1 is invalid 33 | std::vector<Console::ListItem> item; | ^ src/../lib/src/MenuWindow.hpp:33:38: error: template argument 2 is invalid In file included from src/Main.cpp:2: src/MainScreen.hpp:25:14: error: ‘ListWindow’ in namespace ‘Console’ does not name a type 25 | Console::ListWindow menu; | ^~~~~~~~~~ make[1]: *** [Makefile:25: obj/Main.o] エラー 1 make[1]: ディレクトリ '/home/shigurechan/Program/ScriptEditor' から出ます make: *** [Makefile:56: all] エラー 2 shigurechan@shigurechan-System-Product-Name:~/Program/ScriptEditor$
Console.hpp
cpp
1#ifndef ___CONSOLE_HPP___ 2#define ___CONSOLE_HPP___ 3 4#include <iostream> 5#include <glm/glm.hpp> 6#include <ncurses.h> 7#include "Debug.hpp" 8#include "Help.hpp" 9#include "MenuWindow.hpp" 10//#include "ListWindow.hpp" 11 12namespace Console 13{ 14 struct ListItem 15 { 16 std::string title; 17 Console::ColorPair color; 18 int renderOption = 0; 19 }; 20 21 22 #define LINE_BUFFER ((int)1000) 23 24 void Init(); //初期化 25 26 void SetDispInput(bool b); //入力文字 27 void SetInputBuffer(bool b); //入力バッファ 28 void SetDispCursor(WINDOW *win,bool b); //カーソル 29 void SetKeyPad(WINDOW *win,bool b); //特殊キー 30 31 void RenderBuffer(WINDOW *win); //バッファー描画 32 void ClearBuffer(WINDOW *win); //バッファークリア 33 34 void Close(); //プログラム終了 35 36 //デバッグ 37 void Init_Log(const char* fileName); //ログファイルを指定 38 void Init_File(const char* fileName); //テキストファイルを指定 39 void Init_ErrorLog(const char* fileName); //エラーログファイルを指定 40 41 void Write(const char* fmt,...); //logFileに書き込み 42 void WriteLine(const char* fmt,...); //logFileに書き込み 改行 43 44 void Write_File(const char* fileName,const char* fmt,...); //指定したログファイルに書き込み 45 void Write_FileLine(const char* fileName,const char* fmt,...); //指定したログファイルに書き込み 改行 46 47 48 //描画 49 void RenderString(ColorCode fg,ColorCode bg,WINDOW *win,glm::ivec2 pos,const char* fmt,...); 50 51 void RenderString_Bold(ColorCode fg,ColorCode bg,WINDOW *win,glm::ivec2 pos,const char* fmt,...); 52 53 void RenderString_Blink(ColorCode fg,ColorCode bg,WINDOW *win,glm::ivec2 pos,const char* fmt,...); 54 55 void RenderString_UnderLine(ColorCode fg,ColorCode bg,WINDOW *win,glm::ivec2 pos,const char* fmt,...); 56 57 glm::ivec2 GetScreenSize(WINDOW* win); //画面サイズを取得 58 std::string InputString(); //文字列入力 59 int Input(); //文字入力 60 61 62 63 64} 65#endif 66
MenuWindow.hpp
cpp
1#ifndef ___MENUWINDOW_HPP___ 2#define ___MENUWINDOW_HPP___ 3#include <string> 4#include <vector> 5#include <ncurses.h> 6#include <glm/glm.hpp> 7#include "Console.hpp" 8namespace Console 9{ 10 class MenuWindow 11 { 12 public: 13 14 15 MenuWindow(); 16 ~MenuWindow(); 17 18 19 20 void SetItem(Console::ListItem i); 21 22 void Render(WINDOW *win,glm::ivec2 pos); 23 void Update(); 24 void SetCursorDown(); 25 void SetCursorUp(); 26 27 28 private: 29 30 31 32 Console::ColorPair selectColor; 33 std::vector<Console::ListItem> item; 34 glm::ivec2 cursorPosition; 35 glm::ivec2 cursor = glm::ivec2(0,0); 36 }; 37 38} 39#endif
Main.cpp
cpp
1#include <iostream> 2#include "MainScreen.hpp" 3#include <memory> 4//#include <Magick++.h> 5#include "../lib/src/Console.hpp" 6 7 8int main() 9{ 10 Console::Init(); 11 Console::Init_ErrorLog("log/error.log"); 12 Console::Init_Log("log/log.log"); 13 14 Console::RenderBuffer(NULL); 15 16 17 std::unique_ptr<MainScreen> main = std::make_unique<MainScreen>(); 18 19 while(true) 20 { 21 main->Loop(); 22 23 if (main->getExit() == true) 24 { 25 break; 26 } 27 } 28 29 Console::Close(); 30 31 return 0; 32} 33
MainScreen.hpp
cpp
1#ifndef ___MAINSCREEN_HPP___ 2#define ___MAINSCREEN_HPP___ 3#include <vector> 4#include <filesystem> 5#include <glm/glm.hpp> 6#include "../lib/src/Console.hpp" 7 8 9class MainScreen 10{ 11 12public: 13 MainScreen(); 14 ~MainScreen(); 15 16 void Loop(); 17 18 bool getExit(); 19private: 20 21 void Update(); 22 void Render(); 23 void KeyInput(); 24 25 Console::ListWindow menu; 26 27 28 glm::ivec2 cursorPosition; 29 bool isExit = false; 30}; 31 32 33#endif 34
Main.cpp を提示してください。
その中で
#include "MenuWindow.hpp"
#include "Console.hpp"
とでも書いてあったらそれが原因ですね。

なるほど自己解決ようにして解決したのですがConsole::ListItem とListItemは何が違うのでしょうか?名前空間を指定しなのとそうじゃない場合です。同じ名前空間で

回答2件
あなたの回答
tips
プレビュー