c++ - _Longlong 未在此范围内声明

标签 c++ sdl-2

我正在阅读lazyfoo.net 上的SDL 2 教程的教程33(源代码可在页面底部的http://lazyfoo.net/tutorials/SDL/33_file_reading_and_writing/index.php 处获得),并且我收到编译器错误“_Longlong 未在此范围内声明” ”。我在 Codeblocks 16.01 中使用 g++ 5.3 版。我该如何解决此构建错误?

最佳答案

这就像示例中的错误(不可移植编码),如 https://forums.libsdl.org/viewtopic.php?p=42648 中报告的那样作者:jungletek,2015 年:

I posted this in a newer thread about the same issue, it's sad that people never follow up with their solutions on the internet...

Quote: I believe this is a combination of a MinGW bug (update MinGL to a newer version), and a bug/error(?) with Lazy Foo's code.

Changing all instances of '_Longlong' to 'long long' causes the code to compile properly, and the executable seems to perform as expected, as far as I can see. If anyone can let me know if this is in some way an incorrect solution, I'd love to hear it as I'm still very much in the process of learning.

Also make sure you're compiling for the c++11 standard, using the proper compiler flags.

因此,您可以尝试将 typedef 为 _Longlong 的行(在首次使用 _Longlong 之前)添加到 long long 中(在许多平台上两者都是 64 位整数):

 typedef long long _Longlong;

而且 _Longlong 听起来太像 something from华盛顿州雷德蒙德的沙漠,这不是 gcc 编译器的主要目标。

关于c++ - _Longlong 未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43624367/

相关文章:

android - SDL2 - 检测 "tablet"与 "phone"或屏幕尺寸

c++ - EnableWindow(hWnd, false) 不禁用键盘输入

c++ - 我如何在 C++ 中封装供一般客户使用的合并排序程序?

c++ - 将 C++ 转换为模板元程序

c++ - 为什么 C++ 允许缺少返回值?

c++ - 当我将大图像添加到 sdl 纹理时,巨大的 fps 下降

c++ - Boost MultiArray 复制构造函数

c++ - 事件驱动的 SDL2

go - 不需要模块提供包 SDL2

opengl - SDL2 和 3D 渲染