草庐IT

package-scoped

全部标签

c++ - "gets() was not declared in this scope"错误

这个问题在这里已经有了答案:whyg++shows"gets()"notdeclared,evenafterincluding(3个答案)关闭2年前。使用以下代码,我得到“gets()未在此范围内声明”错误:#include#includeusingnamespacestd;intmain(){//stringstr[]={"Iamaboy"};stringstr[20];`gets(str);cout

c++ - 如何使用配置模式进行 find_package 搜索并在模块模式下进行回退?

当一个库使用CMake定义了一个构建并经历了为自己构建安装包的麻烦时,就会有一个XXXConfig.cmake。如果库无法将其目标导出到CMake,CMake会尝试通过提供试图找到此类库的FindXXX.cmake脚本来弥合差距。在文档中,首先尝试使用FindXXX.cmake(模块模式),只有在失败时才会尝试使用XXXConfig.cmake(配置模式).但这对我来说似乎真的很倒退。问题是,例如,我从源代码构建了CURL,ConfigXXX生成了与FindXXX不同的目标名称,因此,当尝试使用它时,它失败了,因为FindXXX负责find_package请求并加载了不同的目标名称超出

c++ - 在顶层使用 shared_ptr 而不是 scoped_ptr 有什么优势吗?

我的团队对于指针容器在特定上下文中的使用存在一些分歧。请考虑:intmain(){//Toplevel.Thisisanimportantfacttothecontext//i.e.thatthefollowinginstanceisatthislevel//sothatitsmembersareessentiallyatprogramscope.MainClassmainClass;mainClass.run();}//AinstanceofaclassderivedfromBufferdoessomethingverycomplex//(ithasvarioushandlestor

c++ - GNU 编译器 vs. Visual Studio 在数组上分配 w/Length Constant w/in a Scope

我知道如果你在c/c++中设置一个动态值,你不能在括号内使用该值来分配一个数组(这会使它成为所谓的可变长度数组(VLA),其中currentC++standard不支持)...即见:C++:VariableLengthArrayhttp://en.wikipedia.org/wiki/Variable-length_array我不太明白(而且我在这里没有看到确切地问到的)是为什么GNUc/c++编译器(gcc、g++)没问题使用基于整数值的动态分配(据我所知),只要该值是数组分配范围内的常量,但VisualStudio不支持这一点并且将拒绝编译代码,吐出错误。例如在g++中voidFo

c++ - boost::scoped_lock 不适用于局部静态变量?

我制作了以下示例程序来使用boost线程:#pragmaonce#include"boost\thread\mutex.hpp"#includeclassThreadWorker{public:ThreadWorker(){}virtual~ThreadWorker(){}staticvoidFirstCount(intthreadId){boost::mutex::scoped_lock(mutex_);staticinti=0;for(i=1;i主类://ThreadTest.cpp#include"stdafx.h"#include"boost\thread\thread.hpp

c++ - "Function not declared in this scope"编译openCV代码出错

我正在尝试编写一些使用openCV函数的代码。我从文档中提供的一些示例代码开始:#include#include#includeusingnamespacecv;usingnamespacestd;intmain(intargc,char**argv){if(argc!=2){cout当我尝试在Eclipse-CDT中构建它时,我得到了这个:****BuildofconfigurationDebugforprojectopenCV1****makeallBuildingtarget:openCV1Invoking:CrossG++Linkerg++-L/usr/local/lib-o"

c++ - (C++) 错误 : 'invalid_argument' was not declared in this scope

我正在使用EclipseC/C++和MinGW编译器。我已将标志-std=c++11添加到项目属性中C/C++Build下的MiscellaneousGCCCCompilerSettings中。我知道这可能是一件简单的事情,但我无法解决此错误。Date.h#includeusingnamespacestd;classDate{public:Date(intm=1,intd=1,inty=1900);voidsetDate(int,int,int);private:intmonth;intday;intyear;staticconstintdays[];};日期.cpp#include#

c++ - C++ 中的 "Variable ' i ' was not declared in scope "是什么?

在练习C++代码时,我使用了在for循环中声明的变量。我希望它在另一个for循环中再次使用它。但它向我显示了一个错误,即variableiwasnotdeclaredinscope我在EclipseIDE中尝试了相同的循环thesymboliwasnotresolved.示例代码与此类似:#includeusingnamespacestd;intmain(){for(inti=0;i 最佳答案 您必须为每个范围声明变量:#includeusingnamespacestd;intmain(){for(inti=0;i在第一个循环之后,

C++:带有 packaged_task 的核心转储

我从http://en.cppreference.com/w/cpp/thread/packaged_task中的部分代码中复制了一个奇怪的核心转储,#include#include#includevoidtask_lambda(){std::packaged_tasktask([](inta,intb){returnstd::pow(a,b);});std::futureresult=task.get_future();task(2,9);std::cout我明白了terminatecalledafterthrowinganinstanceof'std::system_error'w

c++ - C++11 中的 BOOST scoped_lock 替换

我面临这样一种情况,我必须用C++11中的等效项替换BOOSTscoped_lock。在visualstudio2013下。由于c++11不支持scoped_lock,我不确定下面的替换代码是什么。我应该选择lock_guard还是try_lock?boost::mutex::scoped_lockobjectLock(ObjectVectorMutex,boost::try_to_lock);if(objectLock){//...}在代码中我有以下“等待”语句if(ObjectsCollection.empty()){//Thisiswherewewaittilsomethingi