草庐IT

Binary_Compatibility_Issues_With_

全部标签

c++ - 为什么自制的二进制搜索算法比 std::binary_search 慢?

std::binary_search击败了一个简单的自制二进制搜索算法(再次)://gccversion4.8.2X86_64#ifndefEXAMPLE_COMPARE_VERSION#defineEXAMPLE_COMPARE_VERSION0#endifstaticconstlonglongLOOPS=0x1fffffff;#include#include#include#include#ifEXAMPLE_COMPARE_VERSION#includeinlineboolstl_compare(constintl,constintr){returnlv)end=p-1;else

c++ - boost 梅森扭曲器 : how to seed with more than one value?

我正在使用boostmt19937实现进行模拟。模拟需要可重现,这意味着存储RNG种子并可能在以后重复使用。我正在使用windowscryptoapi生成种子值,因为我需要种子的外部来源,而不是因为任何特定的随机性保证。任何模拟运行的输出都会有一个注释,包括RNG种子-所以种子需要相当短。另一方面,作为模拟分析的一部分,我将比较几次运行——但为了确保这些运行实际上不同,我需要使用不同的种子——所以种子需要足够长以避免意外碰撞。我已经确定64位的播种应该足够了;在大约2^32次运行后发生碰撞的可能性将达到50%——这个概率足够低,以至于由它引起的平均错误对我来说可以忽略不计。仅使用32位

c++ - omp for with collapse 子句未编译

我正在使用OpenMP中的并行for结构进行并行处理。在OpenMP规范中,我可以看到:voidsub(float*a){inti,j,k;#pragmaompforcollapse(2)private(i,k,j)for(k=kl;k我写的代码我觉得很相似,但不能编译:unexpectedtokenaftercollapseclause#pragmaompforcollapse(2)for(inti=0;i为什么它不起作用? 最佳答案 collapse是一个OpenMP3.0pragma。您收到的错误消息通常是由于编译器仅实现了O

c++ - g++ : can't link with a main executable file

我正在开发一个使用统计攻击来破解wepkey的应用程序。当我用我的makefile编译时(如上)我得到这个错误:ld:can'tlinkwithamainexecutablefile'execStatAttack'forarchitecturex86_64clang:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)make:*[statAttack]Error1我的项目包含那些文件:statAttack.cpp:包含主要功能,使用上面的文件rc4.h+rc4.cpp:具有那些功能#include#include#i

c++ - XCB 错误 : 148 - Qt application display issues

我正在尝试在另一台计算机上运行我的Qt应用程序(它在我开发它的地方完美运行)。当我通过终端启动此应用程序时,出现此错误-QXcbConnection:XCBerror:148(Unknown),sequence:175,resourceid:0,majorcode:140(Unknown),minorcode:20我的程序确实启动并且一切看起来都正常,但是当我运行它时,我在与显示器交互时看到了奇怪的行为(一些绘画命令没有被执行,这对我的应用程序至关重要)。我已经尝试搜索此错误,但到目前为止我找不到任何解决方案。你有什么建议吗?使用ubuntu16.04,Nvidia1050GTXGPU

c++ - lambda 如何在 MSVC2017 15.9.3 with/std :c++17? 中使用静态本地错误返回值

下面的示例代码打印来自lambda函数的值,该函数简单地递增并返回静态局部计数器变量的值。它打印0,1和2,3正如预期的那样,gcc和C++17的clang。但在VisualStudioCommunity201715.9.3中没有/std:c++17设置-它打印0,0和2,3相反。#includeintmain(){autof=[]{staticinti=0;returni++;};constintv1=f();//Expectv1=0constintv2=f();//Expectv2=1//Printsthewrongvalues(MSVC15.9.3with/std:c++17)s

c++ - 错误 C2678 : binary '=' : no operator found which takes a left-hand operand of type 'const Recipe' (or there is no acceptable conversion)

我正在尝试对每个元素中包含一个int和一个字符串的vector进行排序。它是一个称为vector食谱的类类型的vector。出现上述错误,这是我的代码:在我的Recipe.h文件中structRecipe{public:stringget_cname()const{returnchef_name;}private:intrecipe_id;stringchef_name;在我的Menu.cpp文件中voidMenu::show()const{sort(recipes.begin(),recipes.end(),Sort_by_cname());}在我的Menu.h文件中#include

c++ - 错误 MSB6006 : "cmd.exe" exited with code 1 running QT application

我使用visualstdio2012命令提示符编译了QT5.0.1。当我创建控制台应用程序时,一切都很好并且可以正常工作,但是当我创建QT应用程序时,它会抛出此错误:Error1errorMSB6006:"cmd.exe"exitedwithcode1(已安装QTvisualstdioqt-vs-addin-1.2.0) 最佳答案 打开详细构建输出以查找您的确切问题,工具->选项->项目和解决方案->构建和运行->构建输出和构建日志详细信息。我的问题是错误地使用了“CONST”。(CleanandRebuild似乎可以暂时解决问题,

c++ - constexpr if with initializer 由标准保证吗? 'constexpr(constexpr auto x = f(); x) { }'

我找不到任何关于新C++17if初始化语法的信息和“constexprif”在:http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0128r1.html不过,Clang-HEAD支持该语法...constexprautof(){returntrue;}intmain(){ifconstexpr(constexprautox=f();x){}}在线代码在这里->http://melpon.org/wandbox/permlink/dj3a9ChvjhlNc8nr是constexprif带有标准保证的初始值设定项,如constexpr

c++ - Pimpl with unique_ptr : Why do I have to move definition of constructor of interface to ".cpp"?

只要我不将构造函数(B)的定义移动到标题B.h中,代码就可以工作。B.hclassImp;//imp;B();//B.cpp#include"B.h"#include"Imp.h"B::B(){}~B::B(){}Imp.hclassImp{};Main.cpp(编译我)#include"B.h"Error:deletionofpointertoincompletetypeError:useofundefinedtype'Imp'C2027我能以某种方式理解必须将析构函数移动到.cpp,因为可能会调用Imp的解构:-deletepointer-of-Imp;//somethinglik