compiler limit: string exceeds 65535 bytes in length

Sathish 0 Reputation points
2023-06-22T15:05:54.68+00:00

Hi There,

I had encountered the following error on Visual studio 2017, "fatal error C1091: compiler limit: string exceeds 65535 bytes in length," I have exceeded the maximum allowed length for a string in the Visual Studio 2017 compiler. However, this error is not seen in Visual Studio 2022.

Could you please provide the details of Changelog or release note incase if the following issue is fixed or resolved on the latest Visual Studio 2022.

Thanks,

Sathish

Developer technologies Visual Studio Debugging
Developer technologies Visual Studio Other
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,746 Reputation points
    2023-06-23T14:52:39+00:00

    Hello there,

    The error message "fatal error C1091: compiler limit: string exceeds 65535 bytes in length" indicates that you have encountered a limitation imposed by the C++ compiler you are using. The error occurs when a string literal or a concatenated string in your code exceeds the maximum allowed length of 65535 bytes (64 KB).

    To resolve this issue, you have a few options:

    Shorten the string: If possible, try to reduce the length of the string that is causing the error. You can split it into multiple smaller strings or find ways to minimize its size without compromising the functionality of your code.

    Store the string in a different format: Instead of having an extremely long string literal in your code, consider storing the string in a separate file (such as a text file or a resource file) and read it at runtime. This way, you can avoid the compiler's limit on string length.

    Use string concatenation: If the long string is a result of concatenating multiple smaller strings, you can split the concatenation into multiple smaller operations. This can help you stay within the compiler's limit.

    Refactor your code: If the string is part of a larger code structure, consider refactoring your code to make it more modular and reduce the reliance on extremely long strings.

    Visual Studio 2022 version 17.6 Release Notes https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.