Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio c++ include string maximum length

I've been trying to compile Qt on Windows and I've run into an interesting problem with #includes failing with the error that the file being included does not exist ("No such file or directory"). However the file does exist. The files doing the including are auto-generated "moc" files (made by Qt) that have an include like the following:

#include "../../../../../../../../qt-everywhere-opensource-src-4.8.2/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h"

The string in that include is 127 characters long. There are many "moc" files produced and compiled in the build, but only ones with very long lengths like this (127+ characters) fail.

The files in question happen to be sitting on a UNIX system, shared via Samba to Windows. I was able to work around the issue by creating a symlink and replacing "qt-everywhere-opensource-src-4.8.2" with "qt-4.8.2" in the affected files. The resulting include:

#include "../../../../../../../../qt-4.8.2/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h"

is only 102 characters long and works just fine.

I've searched around and could not find any reference to this. Nor could I replicate the problem outside this Qt build (just making arbitrarily long file names and trying to include them). So it's possible that somehow the nmake makefiles that Qt creates are doing something when they run cl that causes it to reject long includes in some way.

Does anyone have any additional information on this?

like image 344
Scott Minster Avatar asked Aug 15 '12 12:08

Scott Minster


People also ask

What is the maximum length of a string in C#?

What is the max string length in C#? The maximum string length in C# is 2^31 characters. That's because String. Length is a 32-bit integer.

What is the maximum size of string object in c# net?

The maximum size of the String object in memory can be 2GB or about 1 billion characters. Characteristics of String Class: The System. String class is immutable, i.e once created its state cannot be altered.

How long can string be vb net?

Environment String Length. There is a maximum of 32768 characters for any environment string used as a command-line argument.


1 Answers

Since this is used to find the included file, I tend to believe that it is connected to the OS' file path restrictions.

Maybe the implementation of the preprocessor somehow restricts it too, but that would be specific for each and every compiler.

like image 81
SingerOfTheFall Avatar answered Sep 16 '22 15:09

SingerOfTheFall