这感觉很傻,但是从Ubuntu 10.04升级到10.11并从Eclipse Helios升级到Eclipse Indigo之后的某个时间......我遇到了以下问题:
我正在尝试在math.h中使用一个名为isinf()的函数,但问题也出现在像isnan()这样的问题上.
该程序使用make在eclipse中使用make和fine进行编译.
但是如果我在eclipse中打开程序文件,它会报告它无法解析isinf()函数调用.
如果我只是将程序内容插入到新项目和新源文件中,则会立即显示错误.
使用Eclipse Helios CDT在11.04下没有发生此问题
为什么这些错误仅在程序文件打开时报告,而在编译程序时不报告; 为什么未检测到的错误是从命令行运行的?
有解决方案/解决方法吗?
Linux Ubuntu 10.11 64位
Eclipse CDT Indigo,Service Release 1,构建ID:20110916-0149
(也使用Eclipse EE Indigo - 如果有所不同)
GNU Make 3.81
gcc 4.6.1-9Ubuntu3
请在下面找到您需要复制的两个文件:
步骤0.验证Eclipse之外的一切正常
复制附加的源文件并使文件
创建目录,例如Mkdir FunTest
将源文件保存为'Test.cpp',将makefile保存为'makefile'
打开命令提示符并导航到目录例如FunTest
输入'
make'Enter./TestOut
程序响应"不是无限的"
步骤1.在Eclipse中创建项目
打开Eclipse
选择File | New | MakeFile Project with Existing Code
单击Browse - 导航到目录(FunTest)并单击ok
从Toolchain选择器中选择'Linux GCC'
单击Finish
步骤2.找到错误
单击Build All(Ctrl-B) - 项目构建没有错误
在项目资源管理器中打开项目以在目录中显示文件
双击文件"Test.cpp"
注意行旁边的错误图标测试无穷大
注意2错误消息:
Semantic error: Function _isinff …Run Code Online (Sandbox Code Playgroud) 对于使用QT的networkauth和新的QOAuth2AuthorizationCodeFlow对象的OAuth 2.0,如何设置redirect_uri?我的代码如下。它导致发送以下身份验证URL:
QOAuth2AuthorizationCodeFlow :: buildAuthenticateUrl:https ://accounts.google.com/o/oauth2/auth ? client_id = 123-abc.apps.googleusercontent.com & redirect_uri = http://localhost:65535/cb & response_type = code & scope = email & state = iEIYn5sN
将redirect_uri设置为“ http:// localhost ”,会导致Google出现错误400 redirect_uri_mismatch,这显然是希望提供实际的重定向主机名。
GoogleGateway::GoogleGateway() {
auto google = new QOAuth2AuthorizationCodeFlow;
google->setScope("email");
this->connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl);
QString val;
QFile file;
file.setFileName("/home/me/client_secret.json");
file.open(QIODevice::ReadOnly | QIODevice::Text);
val = file.readAll();
file.close();
QJsonDocument document = QJsonDocument::fromJson(val.toUtf8());
QJsonObject object = document.object();
const auto settingsObject = object["web"].toObject();
const QUrl authUri(settingsObject["auth_uri"].toString());
const auto clientId = settingsObject["client_id"].toString();
const QUrl tokenUri(settingsObject["token_uri"].toString());
const …Run Code Online (Sandbox Code Playgroud) 我尝试使用 c++20 std::chrono 替换一些 boost::gregorian 代码,希望消除 boost 构建依赖性。代码正在读取和写入 json(使用 nlohmann),因此将日期与 std::string 相互转换的能力至关重要。
\n\n在 Ubuntu 20.04 上使用 g++ 9.3.0。2 个编译时错误,第一个错误发生在 std::chrono::parse() 上,第二个错误发生在 std::put_time() 上
\n\n对于 std::chrono::parse() 上的错误 A,我在这里看到日历支持 (P0355R7)(包括 chrono::parse)在 gcc libstdc++ 中尚不可用。有人知道这是否正确或者有 ETA 的链接吗?或者我调用 parse() 的方式有问题吗?
\n\n对于 std::put_time() 的错误 B:因为 std::put_time() 被记录为 c++11 感觉我在这里错过了一些愚蠢的东西。还觉得需要通过 c\'s time_t 和 tm 进行隐藏很奇怪。有没有更好的方法将 std::chrono::time_point 直接转换为 std::string 而无需求助于 c?
\n\n#include <chrono>\n#include <string>\n#include <sstream>\n#include <iostream>\n\nint main(int argc, char *argv[]) {\n std::chrono::system_clock::time_point myDate;\n\n //Create time point from string\n //Ref: https://en.cppreference.com/w/cpp/chrono/parse\n std::stringstream …Run Code Online (Sandbox Code Playgroud) 使用 date.h 和 std::chrono 处理日历持续时间算术,但得到了意外的结果。
示例代码是:
#include "date.h"
#include <string>
#include <chrono>
#include <iostream>
int main() {
date::sys_seconds calendarDate = {};
calendarDate = std::chrono::years(30) + date::sys_seconds(std::chrono::days(10));
std::string stringDate = date::format("%Y-%m-%d %H:%M:%S", calendarDate);
std::cout << "{} + 30 years + 10 days = " << stringDate << "\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
实际输出:{} + 30 年 + 10 天 = 2000-01-11 06:36:00
预期输出:{} + 30 年 + 10 天 = 2000-01-11 00:00:00
使用Ubuntu 22.04;克++11.3.0
编译为:gcc -g -std=c++20 main.cpp -lstdc++
在这里使用 date.h fromm: …