草庐IT

c++ - 错误 : incomplete type when using HMAC_CTX in C++ project

我正在尝试编译这个库ndn-cxx在我的笔记本电脑里。我已经在另一台计算机上尝试过并且编译成功但现在我收到此错误并且我认为它与openssl相关。我使用sudoapt-cachesearchlibssl|确认我的笔记本电脑中有openssl|grepSSL结果是:libssl-ocaml-OpenSSL的OCaml绑定(bind)(运行时)libssl-ocaml-dev-OpenSSL的OCaml绑定(bind)libssl0.9.8-SSL共享库libsslcommon2-企业消息传递系统-通用SSL库libsslcommon2-dev-企业消息系统-通用SSL开发文件我在尝试编译

c++ - gcc 与 clang : noexcept parsed in unused template specialization when static casting

我正在尝试将函数指针静态转换为特定函数重载,但似乎clang仍会解析(未使用的)模板特化的noexcept语句,从而生成编译器错误。如果未使用相应的函数重载,GCC似乎并不关心noexcept。templatevoidfun(T)noexcept(T(1)){}voidfun(int){}voidfun(int*){}intmain(){inta;fun(&a);//callingworksfinefun(a);static_cast(&fun);//staticcastingdoesn't}https://godbolt.org/z/ixpl3f这里是哪个编译器出错了?当将函数指针转

c++ - 为什么我收到错误 : initializing argument 1 of 'Item::Item(int)' [-fpermissive] in Eclipse when I try to compile my C++ code?

我是C++的新手,在盯着它看了太久之后终于放弃了尝试编译它。编译器似乎出于某种原因拒绝了头文件中的构造函数原型(prototype)......我无法弄清楚它有什么问题。项目.h:#ifndefITEM_H_#defineITEM_H_classItem{public:Item(int);//ThislineiswhatEclipsekeepsflaggingupwiththeerrorinthetitlevirtual~Item();Item*getNextPtr();intgetValue();voidsetNextPtr(Item*);};#endif/*ITEM_H_*/在我的

c++ - 地址 sanitizer : "SEGV on unknown adress" when using throw-catch and printf

当我扔东西时,例如一个int或一个charconst*,并使用printf检查错误,我得到一个AddressSanitizerError。我无法在网上找到任何类似的东西,而且我的代码示例非常基础,以至于我真的不明白它怎么可能会产生错误。精简代码示例:#includeintmain(){try{throw42;}catch(intmsg){printf("%d\n",msg);}return0;}运行代码时的控制台输出:ASAN:SIGSEGV===================================================================16533=

c++ - boost::interprocess : cout a string variable when iterating through a map that references an object from a struct

我正在使用boost::interprocess在进程之间共享对象。我有两个文件,一个生成结构对象并将该对象传递到具有int索引的映射中的“server.cpp”;和一个“client.cpp”文件,它检索内存数据并遍历数据,输出到控制台。结构看起来像这样:structmydatao{stringMY_STRING;intMY_INT;};和对象:mydatao;o.MY_STRING="hello";o.MY_INT=45;服务器和客户端都能正确编译。但是出于某种原因,如果我尝试访问客户端中的字符串而不是float或整数,客户端可执行文件会抛出段错误。例如下面的second.MY_I

c++ - 警告: "when type is in parentheses, array cannot have dynamic size"?的原因是什么

我已经发布了一个关于与数组的动态内存分配相关的GCC错误的问题:Anerrorisissuedbygccrelativetoparsingtype-idinanewexpression现在使用ClangHEAD10.0.0我收到以下警告:rog.cc:9:37:warning:whentypeisinparentheses,arraycannothavedynamicsizeint(**a)[N3]=new(int(*[n1])[N3]);~~^~~当我运行这个演示程序时:#includeintmain(){constsize_tN3=4;size_tn1=2;int(**a)[N3]

c++ - VS2013 错误 : LNK2019 When trying to build ZeroMQ server

我正在尝试在VisualStudio2013上用C++构建这个简单的ZeroMQ服务器。#include"stdafx.h"#include"zmq.hpp"#include#include#includeusingnamespacestd;int_tmain(intargc,_TCHAR*argv[]){//Preparecontextandsocketzmq::context_tctx(1);zmq::socket_tsckt(ctx,ZMQ_REP);sckt.bind("tcp://*:5555");while(true){zmq::message_trequest;//Wai

c++ - 我们什么时候不应该在构造函数中使用初始化列表?

当我们不应该在构造函数中使用初始化列表时,有人可以引用示例代码吗?如何通过赋值来克服这个问题?我正在寻找以下语句的示例Thismighthappenwhenyourclasshastwoconstructorsthatneedtoinitializethethisobject'sdatamembersindifferentorders.Oritmighthappenwhentwodatamembersareself-referential.Orwhenadata-memberneedsareferencetothethisobject,andyouwanttoavoidacompile

C++ fstream : throwing exception when reaching eof

我想读取两个文件,直到读到其中一个文件的末尾。如果出现问题,fstream应该抛出异常。问题是,设置eof位时也会设置坏位或失败位。ifstreaminput1;input1.exceptions(ios_base::failbit|ios_base::badbit);input1.open("input1",ios_base::binary|ios_base::in);ifstreaminput2;input2.exceptions(ios_base::failbit|ios_base::badbit);input2.open("input2",ios_base::binary|io

c++ - 'Windows.h : No such file or directory"error when changing Platform Toolset to v140_xp

这个问题在这里已经有了答案:HowtotargetWindowsXPinMicrosoftVisualStudioC++[duplicate](2个答案)关闭4年前。我尝试为WindowsXP编译一个应用程序;正常的可执行文件给出错误:"...isnotavalidWin32application."我读到我可以通过将平台工具集更改为VisualStudio2015-WindowsXP(v140_xp)来创建与XP兼容的可执行文件,但是当我这样做然后尝试编译时,它给了我以下错误:Cannotopenincludefile:'Windows.h':Nosuchfileordirector