visual-studio cc1plus: 错误: 包括: 使用 g++ 编译时对于定义的数据类型值太大

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2438890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:39:10  来源:igfitidea点击:

cc1plus: error: include: Value too large for defined data type when compiling with g++

visual-studiog++

提问by A Hymanson

I am making a project that should compile on Windows and Linux. I have made the project in Visual Studio and then made a makefile for linux. I created all the files in Windows with VS.

我正在制作一个应该在 Windows 和 Linux 上编译的项目。我已经在 Visual Studio 中制作了该项目,然后为 linux 制作了一个 makefile。我用 VS 在 Windows 中创建了所有文件。

It compiles and runs perfectly in VS but when I run the makefile and it runs g++ I get

它在 VS 中编译并完美运行,但是当我运行 makefile 并运行 g++ 时,我得到

$ g++ -c -I include -o obj/Linux_x86/Server.obj src/Server.cpp
cc1plus: error: include: Value too large for defined data type
cc1plus: error: src/Server.cpp: Value too large for defined data type

The code is nothing more than a Hello World atm. I just wanted to make sure that everything was working before I started development. I have tried searching but to no avail.

该代码只不过是一个 Hello World atm。我只是想在开始开发之前确保一切正常。我试过搜索但无济于事。

Any help would be appreciated.

任何帮助,将不胜感激。

回答by Paul Ridgway

I have found a solution on Ubuntu at least. I, like you have noticed that the error only occurs on mounted samba shares - it seems to come from g++ 'stat'ing the file, the inode returns a very large value.

我至少在 Ubuntu 上找到了解决方案。我,就像你已经注意到错误只发生在安装的 samba 共享上 - 它似乎来自 g++ 'stat'ing 文件,inode 返回一个非常大的值。

When mounting the share add ,nounix,noserverino to the options, ie:

挂载共享时,将 ,nounix,noserverino 添加到选项中,即:

mount -t cifs -o user=me,pass=secret,nounix,noserverino //server/share /mount

I found the info at http://bbs.archlinux.org/viewtopic.php?id=85999

我在http://bbs.archlinux.org/viewtopic.php?id=85999找到了信息

回答by stefanB

GNU Core Utils:

GNU 核心实用程序:

27 Value too large for defined data type

It means that your version of the utilities were not compiled with large file support enabled. The GNU utilities do support large files if they are compiled to do so. You may want to compile them again and make sure that large file support is enabled. This support is automatically configured by autoconf on most systems. But it is possible that on your particular system it could not determine how to do that and therefore autoconf concluded that your system did not support large files.

The message "Value too large for defined data type" is a system error message reported when an operation on a large file is attempted using a non-large file data type. Large files are defined as anything larger than a signed 32-bit integer, or stated differently, larger than 2GB.

Many system calls that deal with files return values in a "long int" data type. On 32-bit hardware a long int is 32-bits and therefore this imposes a 2GB limit on the size of files. When this was invented that was HUGE and it was hard to conceive of needing anything that large. Time has passed and files can be much larger today. On native 64-bit systems the file size limit is usually 2GB * 2GB. Which we will again think is huge.

On a 32-bit system with a 32-bit "long int" you find that you can't make it any bigger and also maintain compatibility with previous programs. Changing that would break many things! But many systems make it possible to switch into a new program mode which rewrites all of the file operations into a 64-bit program model. Instead of "long" they use a new data type called "off_t" which is constructed to be 64-bits in size. Program source code must be written to use the off_t data type instead of the long data type. This is typically done by defining -D_FILE_OFFSET_BITS=64 or some such. It is system dependent. Once done and once switched into this new mode most programs will support large files just fine.

See the next question if you have inadvertently created a large file and now need some way to deal with it.

27 对于定义的数据类型,值太大

这意味着您的实用程序版本没有在启用大文件支持的情况下编译。GNU 实用程序确实支持大文件,如果它们被编译为这样做的话。您可能需要再次编译它们并确保启用大文件支持。在大多数系统上,这种支持由 autoconf 自动配置。但有可能在您的特定系统上无法确定如何执行此操作,因此 autoconf 得出结论,您的系统不支持大文件。

消息“定义的数据类型的值太大”是在尝试使用非大文件数据类型对大文件进行操作时报告的系统错误消息。大文件被定义为大于有符号 32 位整数的任何东西,或者换句话说,大于 2GB。

许多处理文件的系统调用以“long int”数据类型返回值。在 32 位硬件上,long int 是 32 位,因此这对文件大小施加了 2GB 的限制。当它被发明时,它是巨大的,很难想象需要这么大的东西。时间过去了,今天的文件可能要大得多。在本机 64 位系统上,文件大小限制通常为 2GB * 2GB。我们将再次认为这是巨大的。

在具有 32 位“long int”的 32 位系统上,您会发现无法将其做得更大,并且还保持与以前程序的兼容性。改变它会破坏很多东西!但是许多系统可以切换到新的程序模式,该模式将所有文件操作重写为 64 位程序模式。它们没有使用“long”,而是使用一种名为“off_t”的新数据类型,其大小为 64 位。必须编写程序源代码以使用 off_t 数据类型而不是 long 数据类型。这通常是通过定义 -D_FILE_OFFSET_BITS=64 或其他一些来完成的。它依赖于系统。一旦完成并切换到这种新模式,大多数程序都会很好地支持大文件。

如果您无意中创建了一个大文件,现在需要某种方法来处理它,请参阅下一个问题。

回答by Laszlo

I had similar problem. I compiled a project in a CIFS mounted samba share. With one Linux kernel the compilation was done, but using an other Linux kernel (2.6.32.5), I got similar error message: "Value too large for defined data type". When I used the proposed "nounix,noserverino" CIFS mounting option, the problem was fixed. So in that case there is a problem with CIFS mounting, so the error message is misleading, as there are no big files.

我有类似的问题。我在 CIFS 挂载的 samba 共享中编译了一个项目。使用一个 Linux 内核编译完成,但使用另一个 Linux 内核 (2.6.32.5),我收到类似的错误消息:“已定义数据类型的值太大”。当我使用建议的“nounix,noserverino”CIFS 安装选项时,问题得到解决。所以在这种情况下,CIFS 挂载有问题,因此错误消息具有误导性,因为没有大文件。

回答by lashgar

If you are on mergerfsfilesystem, removing use_inooption will solve the issue: https://github.com/trapexit/mergerfs/issues/485

如果您在mergerfs文件系统上,删除use_ino选项将解决问题:https: //github.com/trapexit/mergerfs/issues/485

回答by Mike Yam

I think your g++ parameters are a bit off, or conflicting.

我认为您的 g++ 参数有点偏离或冲突。

-c compile only
-I directory of your includes (just plain include might be ambiguous. Try full path)
-o outfile (but -c says compile only)

-c 仅编译
-I 包含的目录(只是简单的包含可能不明确。尝试完整路径)
-o outfile(但 -c 表示仅编译)