Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error C2026: string too big, trailing characters truncated #3

Open
jonatino opened this issue Nov 27, 2020 · 5 comments
Open

error C2026: string too big, trailing characters truncated #3

jonatino opened this issue Nov 27, 2020 · 5 comments

Comments

@jonatino
Copy link

jonatino commented Nov 27, 2020

My project fails to compile when trying to embed an angular web application. Compiling VS 2019 msvc.

Here is my binfs.hpp

https://gist.github.com/Jonatino/9bd16b105c12305e2e227c7f4710cba5

@jonatino
Copy link
Author

The longest string literal for my background.png image is 1,585,218 characters.

@jkuri
Copy link
Contributor

jkuri commented Nov 27, 2020

Hi. After googling this I found out library shoud generate strings as

char *s = "very long"
          "string";

instead of

char *s = "very long string";

to make this work in VS on Windows.

@jonatino feel free to open a pull request, otherwise I can take a look next week.

@jonatino
Copy link
Author

@jkuri I think we'd need to take a step farther and chunk them into separate strings entirely; it seems msvc still enforces a 65535 byte length for even contacted strings.

See https://docs.microsoft.com/en-us/cpp/c-language/maximum-string-length?view=msvc-160#:~:text=ANSI%20compatibility%20requires%20a%20compiler,C%20is%20approximately%202%2C048%20bytes.

While an individual quoted string cannot be longer than 2048 bytes, a string literal of roughly 65535 bytes can be constructed by concatenating strings.

And I've just started C++ a few days ago. I can try to get this working if not your help would be appreciated :)

@jkuri
Copy link
Contributor

jkuri commented Nov 27, 2020

sure, you are welcome to open a PR then we can check together.

@jkuri
Copy link
Contributor

jkuri commented Nov 27, 2020

btw, manually converting strings to format I mentioned above make this compile on Windows if I recall correctly, maybe this lib https://github.com/ekg/split can come handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants