草庐IT

gcc_test

全部标签

c++ - 如何使用 Boost.Test 比较文件?

我有两个文件需要比较。我会用这样的东西BOOST_REQUIRE_EQUAL(filename1,filename2); 最佳答案 您可以使用BOOST_CHECK_EQUAL_COLLECTIONS比较文件内容。代码示例:#defineBOOST_TEST_MAIN#include#include#includeBOOST_AUTO_TEST_CASE(test){std::ifstreamifs1("data1.txt");std::ifstreamifs2("data2.txt");std::istream_iteratorb

c++ - gcc: 错误: 无法识别的命令行选项 '-fforce-mem'

我正在尝试在使用armv6hl架构的Pidora上为我的RaspberryPi编译libmad。然而,当在libmad源上运行make时,我发送了错误:gcc:error:unrecognizedcommandlineoption'-fforce-mem'关于如何解决这个问题或解决这个问题的任何想法都很棒!如果您需要更多信息,请告诉我。 最佳答案 正如devnull评论的那样,-fforce-mem在gcc4.3中被删除(参见gcc's-fforce-memoption)。你应该:使用更新版本的库,不再使用此标志通过删除对此选项的所

c++ - 执行限定名称查找时 Clang 和 GCC 之间的不同行为

考虑以下程序:#includenamespaceN{intj=1;}namespaceM{typedefintN;voidf(){std::cout用clang编译它会出现以下编译器错误:prog.cc:10:22:error:'N'(aka'int')isnotaclass,namespace,orenumerationstd::coutGCC不会给出任何编译器错误。我想弄清楚我应该为哪个编译器提交错误报告。哪个编译器具有正确的行为以及原因(对c++标准的引用)?Wandbox-Clang:http://melpon.org/wandbox/permlink/s0hKOxCFPgq5

c++ - clang 的 `-Ofast` 选项在实际中有什么作用,特别是对于与 gcc 的任何差异?

类似于的SO问题Whatdoesgcc'sffast-mathactuallydo?并且与Clangoptimizationlevels的SO问题相关,我想知道什么clang的-Ofast优化在实际方面的作用,这些是否与gcc完全不同,或者这是否比编译器更依赖于硬件。根据clang优化级别的公认答案,-Ofast添加到-O3优化:-fno-signed-zeros-freciprocal-math-ffp-contract=fast-menable-unsafe-fp-math-menable-no-nans-menable-no-infs.这似乎完全与float学相关。但是这些优化对

c++ - gcc 与 clang : inlining a function with -fPIC

考虑这段代码://foo.cxxintlast;intnext(){return++last;}intindex(intscale){returnnext()使用gcc7.2编译时:$g++-std=c++11-O3-fPIC这发出:next():movqlast@GOTPCREL(%rip),%rdxmovl(%rdx),%eaxaddl$1,%eaxmovl%eax,(%rdx)retindex(int):pushq%rbxmovl%edi,%ebxcallnext()@PLT##next()notinlined,callthroughPLTmovl%ebx,%ecxsall%cl

c++ - (int32_t) 255 << 24 是 gcc (C++11) 中的未定义行为吗?

在C++11中,根据en.cppreference.com,Forsignedandnon-negativea,thevalueofaa*2bifitisrepresentableinthereturntype,otherwisethebehaviorisundefined.我的理解是,因为255*224不是表示为int32_t,评价(int32_t)255产生未定义的行为。那是对的吗?这可以吗编译器依赖?如果重要的话,这是一个IP16环境。背景:这来自anargumentIamhaving与arduino.stackexchange.com上的用户。在他看来,“没有什么对此根本没有定

c++ - 使用 stdlibc++ 4.7 启用 C++11 时,出现 clang 错误,而 gcc 编译正常

我一直在努力让C++11工作,在浏览了不同的网站和Q/A之后,我仍然遇到了问题。我想将clang与libstdc++一起使用。在clang状态中表明它受补丁支持-http://clang.llvm.org/libstdc++4.7-clang11.patch.我从macports下载gcc4.7并在gcc4.7的header中进行了相应的更改我不使用libc++的原因是因为libc++和libstdc++之间的ABI兼容性,此线程表明:Whycan'tclangwithlibc++inc++0xmodelinkthisboost::program_optionsexample?好的,一

c++ - 共享内存中的 boost::lockfree::queue 出现问题(boost 1.53、gcc 4.7.2/clang 3.0-6ubuntu3)

我在放置boost::lockfree::queue,..>时遇到问题在共享内存中。我需要它,因为我必须能够将超过65535条消息插入队列,而fixed_sized队列限制为65535。以下代码工作正常(但capacity选项暗示fixed_sized):typedefboost::interprocess::allocatorShmemAllocator;typedefboost::lockfree::queue,boost::lockfree::allocator>Queue;m_segment=newboost::interprocess::managed_shared_memo

c++ - gcc 中的 "Assume"子句

gcc(最新版本:4.8、4.9)是否有类似于icc支持的__assume()内置的“assume”子句?例如,__assume(n%8==0); 最佳答案 从gcc4.8.2开始,gcc中没有__assume()的等价物。我不知道为什么-它会非常有用。马夫索建议:#define__assume(cond)do{if(!(cond))__builtin_unreachable();}while(0)这是一个老把戏,至少可以追溯到2010年,甚至可能更早。编译器通常会优化“cond”的评估,因为任何cond为假的评估无论如何都是未定义

c++ - TEST() 名称中的无下划线规则有多严格?

ThedocumentofGoogleTest说:TEST()argumentsgofromgeneraltospecific.Thefirstargumentisthenameofthetestcase,andthesecondargumentisthetest'snamewithinthetestcase.BothnamesmustbevalidC++identifiers,andtheyshouldnotcontainunderscore(_).这让我很惊讶,因为我通常用下划线命名测试(而不是CamelCase),例如:TEST(foo_test,should_fail_if_e