_Longlong 未在此范围内声明

_Longlong was not declared in this scope

我正在 lazyfoo.net 上学习 SDL 2 教程的教程 33(源代码位于页面底部的 http://lazyfoo.net/tutorials/SDL/33_file_reading_and_writing/index.php),我收到编译器错误“_Longlong在这方面没有申明”。我在 Codeblocks 16.01 中使用 g++ 5.3 版。我该怎么做才能解决此构建错误?

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

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.

因此,您可以尝试将类型定义为 _Longlong 的行(在第一次使用 _Longlong 之前)添加到 long long(在许多平台上都是 64 位整数):

 typedef long long _Longlong;

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