C++
cppBuilder
stringOperation
11

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

動作環境
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++にもあった。

http://www.hellenico.gr/cpp/w/cpp/language/string_literal.html

使おうとした。

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でのエラーを回避できることが分かりました。

情報感謝です。

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

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away