使用Eclipse和minGW的多个"无法解决"问题

 mobiledu2502886633 发布于 2023-02-04 14:02

我最近安装了(最新版本的)'Eclipse IDE for C/C++ Developers'和minGW(4.8.1),以帮助我在很长一段时间后重新使用C++.

我已经加入-std=c++11Other flagsC/C++ Build/Settings/Tool Settings/GCC C++ Compiler/Miscellaneous

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

运行后,我在Problems窗口中遇到多个未解决的问题,如下面的粘贴).

有趣的是,该程序确实编译并运行正常.

    有了这个,我有没有在Eclipse中设置解决这些问题的东西?

    有没有人知道to_string()minGW(4.8.1)中的函数是否仍有问题,例如以下内容无法编译:

    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>> erase(__gnu_cxx::__normal_iterator>>)
 __gnu_cxx::__normal_iterator>> erase(__gnu_cxx::__normal_iterator>>, __gnu_cxx::__normal_iterator>>)
 ' 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

Nabla.. 31

转到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 使用std::to_string.

2 个回答
  • 我在@Nabla和@Enissey给出的答案中添加了一些细节.

    添加命令行参数时,例如,全局首选项中的CDT GCC内置编译器设置Cygwin,

    ${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
    

    这样做,

    ${COMMAND} ${FLAGS} -E -P -v -dD -std=c++11 "${INPUTS}"
    

    要重建索引,请右键单击项目,转到Index子菜单,然后选择"Rebuild".

    就我而言,我在全局范围内进行了更改并重建了索引.

    2023-02-04 14:04 回答
  • 转到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.

    2023-02-04 14:04 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有