gpt4 book ai didi

c++ - 使用带有 minGW 的 Eclipse 出现多个 "could not be resolved"问题

转载 作者:IT老高 更新时间:2023-10-28 22:23:55 24 4
gpt4 key购买 nike

我最近安装了(最新版本)“面向 C/C++ 开发人员的 Eclipse IDE”和 minGW (4.8.1),以帮助我在很久以后重新使用 C++。

我已在 C/C++ Build/Settings/Tool Settings/GCC C++ Compiler/Miscellaneous 将 -std=c++11 添加到 Other flags/

我有一个小程序利用了许多 C++11 特性(例如,使用 chrono 库、.emplace_back)。

运行后,我在“问题”窗口中遇到多个 Unresolved 问题,如下所示)。

有趣的是,该程序确实可以编译并运行。

  1. 有了这个,我没有在 Eclipse 中设置什么来解决这些问题吗?

  2. 有谁知道 minGW (4.8.1) 中的 to_string() 函数是否仍然存在问题,例如以下不编译:

    window.setTitle("Bullets on screen: " + to_string(bullets.size()) + " currentSlice: " + to_string(currentSlice) + " FT: " + to_string(ft) + " FPS: " + to_string(fps) );

    它确实使用 Visual Studio Express 2013 进行编译(尽管 chrono 库的准确性存在问题,因此切换到 minGW)。

    谢谢。

Eclipse“问题”窗口输出:

Description Resource Path Location Type
Symbol 'duration' could not be resolved chronotest.cpp /chronotest/src line 19 Semantic Error
Function 'now' could not be resolved Test2.cpp /Test2/src line 143 Semantic Error
Function 'duration_cast' could not be resolved Test2.cpp /Test2/src line 160 Semantic Error
Function 'now' could not be resolved Test2.cpp /Test2/src line 158 Semantic Error
Symbol 'chrono' could not be resolved Test2.cpp /Test2/src line 8 Semantic Error
Type 'std::centi' could not be resolved chronotest.cpp /chronotest/src line 20 Semantic Error
Type 'std::chrono::seconds' could not be resolved chronotest.cpp /chronotest/src line 24 Semantic Error
Type 'std::time_t' could not be resolved chronotest.cpp /chronotest/src line 48 Semantic Error
Symbol 'duration' could not be resolved chronotest.cpp /chronotest/src line 47 Semantic Error
Function 'now' could not be resolved chronotest.cpp /chronotest/src line 44 Semantic Error
Function 'now' could not be resolved chronotest.cpp /chronotest/src line 39 Semantic Error
Type 'std::chrono::system_clock' could not be resolved chronotest.cpp /chronotest/src line 38 Semantic Error
Function 'end' could not be resolved Test2.cpp /Test2/src line 214 Semantic Error
Symbol 'time_point' could not be resolved chronotest.cpp /chronotest/src line 38 Semantic Error
Function 'end' could not be resolved Test2.cpp /Test2/src line 212 Semantic Error
Type 'milli' could not be resolved Test2.cpp /Test2/src line 161 Semantic Error
Method 'count' could not be resolved Test2.cpp /Test2/src line 161 Semantic Error
Symbol 'duration_cast' could not be resolved Test2.cpp /Test2/src line 160 Semantic Error
Symbol 'duration' could not be resolved Test2.cpp /Test2/src line 161 Semantic Error
Method 'count' could not be resolved chronotest.cpp /chronotest/src line 51 Semantic Error
Symbol 'duration_cast' could not be resolved chronotest.cpp /chronotest/src line 30 Semantic Error
Method 'count' could not be resolved chronotest.cpp /chronotest/src line 30 Semantic Error
Function 'to_time_t' could not be resolved chronotest.cpp /chronotest/src line 48 Semantic Error
Method 'count' could not be resolved chronotest.cpp /chronotest/src line 32 Semantic Error
Function 'ctime' could not be resolved chronotest.cpp /chronotest/src line 50 Semantic Error
Method 'count' could not be resolved chronotest.cpp /chronotest/src line 33 Semantic Error
Symbol 'duration' could not be resolved chronotest.cpp /chronotest/src line 22 Semantic Error
Invalid arguments '
Candidates are:
__gnu_cxx::__normal_iterator<Bullet *,std::vector<Bullet,std::allocator<Bullet>>> erase(__gnu_cxx::__normal_iterator<Bullet *,std::vector<Bullet,std::allocator<Bullet>>>)
__gnu_cxx::__normal_iterator<Bullet *,std::vector<Bullet,std::allocator<Bullet>>> erase(__gnu_cxx::__normal_iterator<Bullet *,std::vector<Bullet,std::allocator<Bullet>>>, __gnu_cxx::__normal_iterator<Bullet *,std::vector<Bullet,std::allocator<Bullet>>>)
' Test2.cpp /Test2/src line 212 Semantic Error
Symbol 'ratio' could not be resolved chronotest.cpp /chronotest/src line 22 Semantic Error
Invalid arguments '
Candidates are:
#0 remove_if(#0, #0, #1)
' Test2.cpp /Test2/src line 212 Semantic Error
Symbol 'duration_cast' could not be resolved chronotest.cpp /chronotest/src line 28 Semantic Error
Method 'count' could not be resolved chronotest.cpp /chronotest/src line 28 Semantic Error
Method 'emplace_back' could not be resolved Test2.cpp /Test2/src line 191 Semantic Error
Symbol 'ratio' could not be resolved chronotest.cpp /chronotest/src line 19 Semantic Error
Symbol 'duration' could not be resolved chronotest.cpp /chronotest/src line 20 Semantic Error
Symbol 'duration' could not be resolved chronotest.cpp /chronotest/src line 21 Semantic Error
Function 'begin' could not be resolved Test2.cpp /Test2/src line 212 Semantic Error
Symbol 'ratio' could not be resolved chronotest.cpp /chronotest/src line 21 Semantic Error

[编辑]:很抱歉没有包含剩余“to_string”的错误详细信息。 Eclipse 的“问题”窗口输出如下:

    Description Resource    Path    Location    Type
'to_string' was not declared in this scope Test2.cpp /Test2/src line 170 C/C++ Problem
Function 'to_string' could not be resolved Test2.cpp /Test2/src line 170 Semantic Error
Function 'to_string' could not be resolved Test2.cpp /Test2/src line 170 Semantic Error
unused variable 'currentSlice' [-Wunused-variable] Test2.cpp /Test2/src line 125 C/C++ Problem
Function 'to_string' could not be resolved Test2.cpp /Test2/src line 170 Semantic Error
Invalid arguments '
Candidates are:
void setTitle(const sf::String &)
' Test2.cpp /Test2/src line 170 Semantic Error
Function 'to_string' could not be resolved Test2.cpp /Test2/src line 170 Semantic Error

最佳答案

转到 Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros, etc. -> Providers -> CDT GCC built-in compiler settings , 停用 Use global provider shared between projects并添加命令行参数 -std=c++11 .

eclipse 实时代码分析不与构建编译器共享相同的设置。您还可以在 Window -> Preferences -> C/C++ -> Build -> Settings -> CDT GCC Built-in Compiler Settings 中全局更改设置(不仅仅是项目) .

编辑:您需要 #include <string>使用 std::to_string .

关于c++ - 使用带有 minGW 的 Eclipse 出现多个 "could not be resolved"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21065616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com