1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ Builder 10.2 Tokyo > String > Raw string literal > 使おうとしてやめた | 想定していたRaw string literalの利点 | 64bitエラー > 解決 (Raw string literalの書き方の間違い)

Last updated at Posted at 2019-05-08
動作環境
RAD Studio 10.2 Tokyo Update 3

状況

fileSL->Add("{\"1_hogehoge\":\"3\", \"2_fugafuga\":\"1\",\"3_hogehoge\":\"4\", \"4_fugafuga\":\"1\", \"5_hogehoge\":\"5\", \"6_fugafuga\":\"9\"}");

JSON文字列を定義。
読みにくい。

Pythonにはraw文字列の定義があった。

C++にもあった。

使おうとした。

32bitの壁

32bitアプリケーションに適用。

> [bcc32 エラー] XXX.cpp(107): E2451 未定義のシンボル R

32bitアプリケーションではだめなのか。

64bitでのエラー

64bitアプリケーションにしてみた。

> ... error E743: 生の文字列の区切りが 16 文字を超えています。生の文字列を区切るには <プレフィックス>( )<プレフィックス> を使用してください

Raw string literalにする利点が減るな。

やめた。

短い文字列に対しては使うのはいいが、(32bitユーザがいることを知っていて)32bitを切ってまでRaw string literalを使うのはしない。
(数年後には32bitユーザがいないかどうか)

想定していたRaw string literalの利点

  • A. ソースリーディングの負荷が減る
  • B. JSONファイルの内容をそのままString定義に利用できる
    • エスケープシーケンスを文字列中に入れる作業が不要

関連

情報感謝です。

64bitエラー > 解決

@yumetodoさんのコメントから再検討した結果、64bitでのエラーを回避できることが分かりました。

情報感謝です。

対応をコメントに書きました。

1
2
11

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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?