Cygwin gcc c++ c99 库错误 stod 无法识别使用的 strtod
Cygwin gcc c++ c99 libraries error stod not recognized used strtod instead
这个问题是继:C ++将文本文件中的C++读取到Vector
到目前为止的代码:
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
#include <cstdlib>
#if __cplusplus < 201103L
#warning No C++11 support
#endif
#if !defined(_GLIBCXX_USE_C99)
#warning No C99 library functions
#endif
#if defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)
#warning Broken vswprintf
#endif
std::vector<double> GetValues(const std::vector<std::string>& src, int start, int end, std::string typeline)
{
std::vector<double> ret;
for(int i = start; i <= end; ++i)
{
if(typeline == "E3T" && i == 5)
{
ret.push_back(std::strtod(src[2].c_str(), nullptr));
ret.push_back(std::strtod(src[i].c_str(), nullptr));
}
else
{
ret.push_back(std::strtod(src[i].c_str(), nullptr));
}
}
return ret;
}
void PrintValues(const std::string& title, std::vector<std::vector<double>>& v)
{
std::cout << title << std::endl;
for(size_t line = 0; line < v.size(); ++line)
{
for(size_t val = 0; val < v[line].size(); ++val)
{
std::cout << v[line][val] << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;
}
int main()
{
std::vector<std::vector<std::string>> values;
std::ifstream fin("example.2dm");
for (std::string line; std::getline(fin, line); )
{
std::istringstream in(line);
values.push_back(
std::vector<std::string>(std::istream_iterator<std::string>(in),
std::istream_iterator<std::string>()));
}
std::vector<std::vector<double>> cells;
std::vector<std::vector<double>> nodes;
for (size_t i = 0; i < values.size(); ++i)
{
if(values[i][0] == "E3T")
{
cells.push_back(GetValues(values[i], 1, 5, "E3T"));
}
else if(values[i][0] == "E4Q")
{
cells.push_back(GetValues(values[i], 1, 6, "E4Q"));
}
else if(values[i][0] == "ND")
{
nodes.push_back(GetValues(values[i], 1, 4, "ND"));
}
}
PrintValues("Cells", cells);
PrintValues("Nodes", nodes);
return 0;
}
编译警告(cygwin gcc c++):
$ g++ read_csv3.cpp -std=c++11
read_csv3.cpp:15:2: warning: #warning No C99 library functions [-Wcpp]
有人知道如何在 cygwin 中解决这个问题吗?
你可能想要这个:
if(typeline == "E3T" && i == 5)
^^ equality check
if(typeline == "E3T" && i = 5)
抱怨左值
因为typeline == "E3T" && i
不能被分配为 5
然而
if(typeline == "E3T" && (i = 5))
编译,但这不是你需要的
相关文章:
- 提升 ASIO 无法识别计时器对象
- 从udp接收帧对于人脸识别来说太慢
- 模板类无法识别友元运算符
- std::visit无法识别类型
- 无法识别模板功能
- 我有两个类需要在同一 cpp 文件中相互引用,但第一个类无法识别第二个类类型的对象
- 如何在LLVM中dyn_cast以识别StoreInst?
- 从不同的附加依赖项中识别等同命名的函数
- C++出现控制台错误.我无法识别源代码的问题
- VSCode IntelliSense无法识别SDL框架的SDL_image扩展库
- Qt:"Q3DScatter"即使包含在内也无法识别
- 使用指针的类识别
- 如何静态识别动态堆分配?
- 为什么C++无法识别我的对象实例化?
- C++ 无法识别创建进程'telnet'
- 识别 2D 矢量C++中的位置
- 如何识别项目是 QT 中的文件还是文件夹
- ESP32 无法识别任何设备已连接到其接入点
- 无法识别 Mac c++ 文件系统库
- Cygwin gcc c++ c99 库错误 stod 无法识别使用的 strtod