[c++対処法] deprecated conversion from string constant to ‘char*’

c++でコンパイルをしようとすると

 deprecated conversion from string constant to ‘char*’

という警告が出ることへの対策。

変更の予定のない文字定数の引数にconstをつけることで解決。

たとえば
int testfunction( char keyword[])

int testfunction( const char keyword[])
に変更。

○追記:
直訳すると「string定数からchar*への変換は推奨されていない」ということ。

正直言うと、なんでこれで警告が起きなくなるのかあまり理解できていない。
C++に詳しい人がいたらコメントください。

カテゴリー: Tips   パーマリンク

[c++対処法] deprecated conversion from string constant to ‘char*’ への6件のコメント

  1. Other than this, the low personal and company tax rates, enterprise-friendly authorities insurance policies, highly educated folks, and most importantly, Singapore being a company hub of Southeast Asia collectively make it a lucrative destination for the investors.

  2. IDProperti より:

    This article is a gem, thanks for sharing! Regards, Pasang Iklan Properti Gratis

  3. Engaging and thought-provoking, as always Thanks for sharing! IDProperticom

  4. He spent his childhood and teen years within the Minnesota towns of Staples and Plainview, where he graduated from highschool.

  5. The combination of the independence gained from highly effective, cellular expertise and the fixed sense of affirmation from their mother and father has produced a way of entitlement in Gen Z that can be seen as a double-edged sword.

  6. But with a reliable EPM software, managing remote employees can turn out to be accomplished in a breeze.

コメントをどうぞ

メールアドレスが公開されることはありません。

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>