草庐IT

compilation-time

全部标签

c++ - C1001 : An internal error has occurred in the compiler

这应该是不言自明的。我正在尝试实现分布排序,但MSVC编译器崩溃了。这似乎是用我的SFINAE检测成员函数的特定情况,如果我不将indexert传递给函数,或者替换has_get_index,这似乎不会发生。如果我删除剩余的索引器重载中的任何一个,它也不会发生。如果sortable有一个getIndex()const成员,问题仍然存在。1>test.cpp(34):fatalerrorC1001:Aninternalerrorhasoccurredinthecompiler.1>(compilerfile'msc1.cpp',line1420)1>Toworkaroundthispro

c++ - CMake + 库达 : compile cpp files in Cuda-mode (--x=cu)

假设我有一个文件,我们称它为foo.cpp,我的目标是在cuda模式下用nvcc编译这个文件。在命令行中,这可以通过调用轻松完成:nvcc--x=cufoo.cpp我正在苦苦挣扎的是让CMake做同样的事情。事实证明,CMake命令cuda_add_executable(foofoo.cpp)将过滤*.cpp文件并使用c++编译器(而不是nvcc)。请注意,将所有文件重命名为*.cu不是一种选择,因为代码库还必须支持非cuda构建。 最佳答案 在FindCUDAsourcecode我找到了一个选项来为特定的非.cu文件激活CUDA编

c++ - 使用 std::get_time 将时间字符串转换为 std::time_t:错误结果

我正在尝试按时间顺序对照片进行排序。因此,我从EXIF数据中将时间提取为字符串,然后将其转换为std::time_t。但是我有时会得到不正确的结果。我已将问题简化为这个最小的例子。它具有三个时间字符串,相隔一秒:#include#include#include#include#include#includeintmain(){std::vectorvec;vec.push_back("2016:07:3009:27:06");vec.push_back("2016:07:3009:27:07");vec.push_back("2016:07:3009:27:08");for(auto&

c++ - boost::date_time, g++-4.7.0, 编译错误

以下代码在g++-4.7.0下出现编译错误,但在g++-4.6下编译正常。#include#includeusingnamespacestd;intmain(){boost::posix_time::ptimetime_t_epoch(boost::gregorian::date(1970,1,1));cout下面是反复看到的错误信息(编译器输出了很多信息)/usr/include/boost/date_time/local_time/local_date_time.hpp:433:84:error:useofdeletedfunctionboost::shared_ptr>::sha

c++ - 为什么 std::timed_mutex::try_lock_for 不起作用?

我在Ubuntu12.04中使用gcc-4.8.1(configure:./configure--prefix=/usr/local)编译了以下代码,但是当我运行它时,它没有工作。它没有停下来等待互斥量。它返回false,并输出“Helloworld!”命令:g++-std=c++11main.cpp-omain-pthread当我用gcc-4.6(apt-getinstallg++)编译时,效果很好。程序等了大概十秒,输出了“Helloworld!”#include#include#include#includestd::timed_mutextest_mutex;voidf(){t

c++ - std::random_shuffle 产生相同的结果,即使 srand(time(0)) 被调用一次

在一个函数中,我想生成一个范围内的数字列表:(该函数只会在程序执行时被调用一次。)voidDataSet::finalize(doubletrainPercent,boolgenValidData){srand(time(0));printf("%d\n",rand());//indices={0,1,2,3,4,...,m_train.size()-1}vectorindices(m_train.size());for(size_ti=0;i结果是这样的:850577673246239710241201288231237几秒钟后:856981140246239710241201288

pygame中time

系统方法pygame.time.get_ticks()pygame.time.wait()pygame.time.delay()pygame.time.set_timer()pygame.time.Clockpygame.time.Clock.tick()pygame.time.Clock.tick_busy_loop()pygame.time.Clock.get_time()pygame.time.Clock.get_rawtime()pygame.time.Clock.get_fps()系统方法pygame.time.get_ticks()功能:(以毫秒为单位)获取时间get_ticks(

c++ - VC++ 使用 fp :fast causes wrong (not just inaccurate) results - is this a compiler bug?

我已经安装了最新的VS2017更新(15.4.4),但在编译我们的项目时,单元测试开始失败。在使用优化(/O2)和浮点快速模型(/fp:fast)时,问题似乎发生在某些情况下。以前的编译器(VS2017update15.2)没有出现这个问题。这是一个示例程序:#includeconstfloatFACTOR=0.01745329251994329576923690768489f;unsignedlonglonghoursToMicrosecs(inthours){returnhours*3600*1000000LL;}floatdegToRad(floatdeg){returndeg*

c++ - Boost C++ date_time microsec_clock 和 second_clock

我在BoostC++日期时间库中发现了一个奇怪的结果。microsec_clock和second_clock之间存在不一致,我不明白为什么会这样。我使用的是WindowsXP32位我的代码片段:usingnamespaceboost::posix_time;...ptimenow=second_clock::universal_time();std::cout我期望的打印输出是没有毫秒和毫秒的当前时间。但是,我的电脑中有:2009-10-14T16:07:381970-06-24T20:36:09.375890我不明白为什么我的microsec_clock时间里有一个奇怪的日期(197

c++ - 将 int64_t 转换为 time_duration

我想通过网络传输boost::posix_time::ptime作为boost::int64_t。根据Awaytoturnboost::posix_time::ptimeintoan__int64,我可以很容易地定义我自己的epoch并且仅将time_duration从该引用epoch传输为64位整数。但是如何转换回ptime呢?#include#include#include#includeusingnamespacestd;usingboost::posix_time::ptime;usingboost::posix_time::time_duration;usingboost::