编译错误之error C3861: “GetDynamicTimeZoneInformation”: 找不到标识符
2018-03-06 18:34
1056 查看
我的电脑是Win10 64位电脑,用的VS2015编译,出现编译错误,error C3861: “GetDynamicTimeZoneInformation”: 找不到标识符;
该标志符定义在timezoneapi.h中,报错的地方是os.h,这类系统头文件中用到该标志符。我试图将timezoneapi.h该头文件包含进工程目录,发现还是解决不了问题;索性将os.h中的内容更改解决了问题,问题猜想是由于win10系统问题。
编译提示函数需要有输出,所以只注释掉以上备注有“注释掉”部分代码,使函数有return值。由于系统是windows系统,所以就强制用了#ifdef _WIN32;自此,编译通过。
该标志符定义在timezoneapi.h中,报错的地方是os.h,这类系统头文件中用到该标志符。我试图将timezoneapi.h该头文件包含进工程目录,发现还是解决不了问题;索性将os.h中的内容更改解决了问题,问题猜想是由于win10系统问题。
inline int utc_minutes_offset(const std::tm& tm = details::os::localtime()) { #ifdef _WIN32 //#if _WIN32_WINNT < _WIN32_WINNT_WS08 //注释掉 TIME_ZONE_INFORMATION tzinfo; auto rv = GetTimeZoneInformation(&tzinfo); //#else //注释掉 // DYNAMIC_TIME_ZONE_INFORMATION tzinfo; //注释掉 // auto rv = GetDynamicTimeZoneInformation(&tzinfo); //注释掉 //#endif //注释掉 // if (rv == TIME_ZONE_ID_INVALID) //注释掉 // throw spdlog::spdlog_ex("Failed getting timezone info. ", errno); //注释掉 // int offset = -tzinfo.Bias; if (tm.tm_isdst) offset -= tzinfo.DaylightBias; else offset -= tzinfo.StandardBias; return offset; #else #if defined(sun) || defined(__sun) // 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris struct helper { static long int calculate_gmt_offset(const std::tm & localtm = details::os::localtime(), const std::tm & gmtm = details::os::gmtime()) { int local_year = localtm.tm_year + (1900 - 1); int gmt_year = gmtm.tm_year + (1900 - 1); long int days = ( // difference in day of year localtm.tm_yday - gmtm.tm_yday // + intervening leap days + ((local_year >> 2) - (gmt_year >> 2)) - (local_year / 100 - gmt_year / 100) + ((local_year / 100 >> 2) - (gmt_year / 100 >> 2)) // + difference in years * 365 */ + (long int)(local_year - gmt_year) * 365 ); long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour); long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min); long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec); return secs; } }; long int offset_seconds = helper::calculate_gmt_offset(tm); #else long int offset_seconds = tm.tm_gmtoff; #endif return static_cast<int>(offset_seconds / 60); #endif }
编译提示函数需要有输出,所以只注释掉以上备注有“注释掉”部分代码,使函数有return值。由于系统是windows系统,所以就强制用了#ifdef _WIN32;自此,编译通过。
相关文章推荐
- 编译错误之error C3861: “xxxx”: 找不到标识符
- 编译错误之error C3861: “xxxx”: 找不到标识符
- 编译错误之error C3861: “getline”: 找不到标识符的问题
- 编译错误之error C3861: “getline”: 找不到标识符
- 编译错误之error C3861: “getline”: 找不到标识符
- HM低版本用VS2012打开编译错误问题error C3861: “mem_fun”: 找不到标识符
- Cacti编译安装错误: Warning: strtotime(): It is not safe to rely on the system's timezone settings.
- 编译使用 libmp4v2库 libmp4v2.lib(atom_tkhd.obj) : error LNK2001: 无法解析的外部符号 _gettimeofday 错误解决办法.
- assert()函数介绍 (错误4 error C3861: “ASSERT”: 找不到标识符)
- 编译错误:undefined reference to `clock_gettime'
- error C3861: “time”: 找不到标识符
- C++ 错误 2 error C3861: “__cpuidex”: 找不到标识符
- error C3861: “time”: 找不到标识符
- cuda 8.0 vs2012平台 编译出现 cuda8.0 error C3861: “__syncthreads”: 找不到标识符
- MIPS下编译QT4.8.0的__tls_get_addr找不到错误
- 错误 1 error C3861: “AfxMessageBox”: 找不到标识符 e:\c++\test\udptest20120901\udptest20120901\udptest2012090
- xcode编译错误:xcode codesign failed resource fork, Finder information, or similar detritus not allowed
- 关于Linux(ubantu12.04)下编译错误mysql.h找不到的问题
- Visual Studio 2010 error C3861: “exit”: 找不到标识符
- error c3861 :"_T":找不到标识符