LoginSignup
0
0

More than 5 years have passed since last update.

c++ builder XE4 > エラー > 長すぎたため切り捨てられた行があります。. > 3200文字はだめ > 文字列リテラル255文字制限

Last updated at Posted at 2016-09-05
動作環境
C++ Builder XE4

テスト用のダミー文字列をString型で定義しようとした。

static const String kDummyText = L"DummyText";

上記のダミー文字列に3200文字の文字列を入れたところ、以下のエラーが表示された。

qiita.png

どこで切り捨てられたか見ようとしたらIDEが固まった。

以下のincludeを使った方法は問題ないのだろうか?
http://qiita.com/7of9/items/cb2fdeba5ad0d232311e

includeを使った方法でも同じエラーが出た。

以下を見つけた。
http://stackoverflow.com/questions/8767899/how-can-delphi-string-literals-be-more-than-255

answered Jan 7 '12 at 7:14
Mikael Eriksson
So string is not limited to 255 characters but a string literal is. That means that you can build a string that is longer than 255 characters but you can not have a string value in code that is longer than 255 characters. You need to split them if you want that.

LoadFromFile()など使ってファイルから読込むときは制約はないが、文字列リテラルとしては255文字の制約があるようだ。

同じ人(Mikael Eriksson)の回答で255文字以内の文字列リテラルを複数くっつけることはできそうだが、3200文字を255文字ごとに区切るのと、LoadFromFile()を実装をするのとでは、後者の方が変化に対応できる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0