GNU GCC代码块win32函数未声明
GNU GCC Codeblocks win32 function not declared
这是我的项目(Implot(中库的一段代码:
#ifdef _WIN32
t.S = _mkgmtime(ptm);
...
#ifdef _WIN32
if (gmtime_s(ptm, &t.S) == 0)
...
#ifdef _WIN32
if (localtime_s(ptm, &t.S) == 0)
该项目刚刚从Visual Studio 2019移植到Codeblocks(C++17(。由于某种原因,这无法编译,当我搜索错误时,我在网上找不到任何东西。
error '_mkgmtime' was not declared in this scope
error 'gmtime_s' was not declared in this scope
error 'localtime_s' was not declared in this scope
我知道这些错误是因为缺少函数,很可能是由于缺少包含文件,但这些错误已在Visual Studio 2019中使用,没有对任何源代码进行任何更改,并且在那里运行良好。为什么这不起作用?我该如何解决?
如果您阅读Visual Studio预定义的宏文档,您可以找到编译器特定的宏,这些宏将用于确定您的代码是否由Visual Studio C++编译器生成。
例如_MSC_VER
宏,您可以检查它而不是_WIN32
。
如:
#ifdef _MSC_VER
auto result = gmtime_s(ptm, &t.S);// Visual Studio
#else
auto result = gmtime(ptm); // Anything else (like e.g. GCC)
#endif
if (result == nullptr) ...
相关文章:
- 函数未在作用域中声明 / 如何结合使用 header.h、header.cpp 和 main.cpp?
- 我的函数调用 (C++) 中的未声明标识符
- 未定义与已删除与未声明的函数
- C++ 在 CentOS7 中与 g++ 的 DLL 链接后未声明的函数
- 由于值返回函数中的错误,程序无法编译.它说未声明的标识符
- 为什么 C 允许我调用未声明的函数?
- 'temp'未声明,请先使用此函数
- C 如何从构造函数中声明(错误C2065未宣布的标识符)
- 函数未在此范围内声明
- 尝试使用 std::函数(未定义的符号)声明模板化类状态时出现链接错误
- makefile 和 lex+yacc 中的错误 -> 错误:"noyywrap"未声明(在此函数中首次使用)
- 我们如何有证据表明,声明虚拟函数的类是2个字节,其中一个不超过一个未声明,而在子类中
- 函数参数中未声明和未定义的标识符
- 在此范围错误中未声明函数错误
- 类 'MainWindow' 中未声明任何成员函数
- 错误C2509:成员函数未在派生类中声明
- C++成员函数未声明错误时(当它看起来是错误时)
- 函数未声明(首先使用此函数)
- 函数未声明简单程序
- 无法调用 VBO 实现所需的函数...未声明错误