我正在阅读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/