backward_warning.hによる警告

このQ&Aのポイント
  • Cygwin上で、自作のヘッダファイルを使用したC++のソースコードをビルドする際に、backward_warning.hからの警告が表示されました。
  • 警告の指示に従い、-Wno-deprecatedを使用し、問題なく開発を続けることができます。
  • __DEPRECATEDが定義されているために警告が表示されているが、その意味は分からないので、知識のある方に教えてほしいです。
回答を見る
  • ベストアンサー

backward_warning.hによる警告

こんにちは。 独自で作成した、C:\Emacs_for_Windows\My_C++_Header_for_Bash.hというファイルパスを持つヘッダファイルをインクルードしているC++のソースファイルのtest.cppを、Cygwinのbash上で、g++コマンドを使い、 g++ test.cpp のようにビルドしたところ、以下のような警告が出ました。 ------------------------------------------------------------ bin/../lib/gcc/i686-pc-cygwin/4.3.4/include/c++/backward/strstream:51 から include されたファイル中, C:\Emacs_for_Windows\My_C++_Header_for_Bash.h:35 から, test.cpp:2 から: /bin/../lib/gcc/i686-pc-cygwin/4.3.4/include/c++/backward/backward_warning.h:33:2: 警告: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. ------------------------------------------------------------ Borland C++ Compiler 5.5 のbcc32コマンドでは、こういった警告は出ません。 /bin/../lib/gcc/i686-pc-cygwin/4.3.4/include/c++/backward/backward_warning.h:33 を参考に、backward_warning.hの33行目以降をみると、以下のようになっていました。 ------------------------------------------------------------ #ifdef __DEPRECATED 33 #warning \ 34 This file includes at least one deprecated or antiquated header which \ 35 may be removed without further notice at a future date. Please use a \ 36 non-deprecated interface with equivalent functionality instead. For a \ 37 listing of replacement headers and interfaces, consult the file \ 38 backward_warning.h. To disable this warning use -Wno-deprecated. ------------------------------------------------------------ どうやら「__DEPRECATED」が定義されているので、こういった警告が出ているようなのですが、 __DEPRECATEDの意味が分かりません。 警告の指示通り、-Wno-deprecatedを付けたままC++開発を続けて問題ないのでしょうか? ちなみに、C:\Emacs_for_Windows\My_C++_Header_for_Bash.hの内容は以下の通りです。 ------------------------------------------------------------ #ifndef MYHEADER_H #define MYHEADER_H //C言語のヘッダファイル #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <time.h> #include <math.h> #include <stddef.h> //C++言語のヘッダの標準識別子 #include <iostream> #include <fstream> #include <cctype> #include <cstring> #include <cstdlib> #include <ctime> #include <cstdio> #include <new> #include <iomanip> #include <strstream> #include <typeinfo> //STLに関するヘッダ #include <string> #include <vector> #include <deque> #include <list> #include <set> #include <map> #include <algorithm> #include <functional> #include <utility> #include <numeric> #include <cassert> #include <iterator> //namespaceの解決 using namespace std; #endif ------------------------------------------------------------ 以上の件について何かご存知の方がいらっしゃれば、是非教えて頂きたいと思います。 では、よろしくお願い致します。

質問者が選んだベストアンサー

  • ベストアンサー
回答No.1

deprecated=非推奨 strstream は旧いから使ってほしくない、と言うてます。 # 今なら sstream でしょうね。

MetalLover
質問者

お礼

御回答ありがとうございます。 なるほど、それだけのことだったのですね。 了解しました。

関連するQ&A

  • C++でコンパイルするとwarningが出ます

    C++初心者です。 C++でコンパイルすると以下のようなwarningメッセージが出るのですが、どういう意味なんでしょうか?解決策があれば教えてください。 プログラム(sample.cpp) #include <iostream.h> main(){ cout << " sample \n"; } warningメッセージ In file included from /usr/include/c++/3.3.1/backward/iostream.h:31, from sample.cpp:1: /usr/include/c++/3.3.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider usin g one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <s stream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated

  • iostreamについて

    今までOSはTurbo Linux 7を使っていましたが、最近RedHatLinux9にかえました。 それで、今までは普通に出来ていたことが出来なくなったので質問します。どちらかと言うとプログラム系の亊ですけど、Windowsではこんなことは起きないのでここで質問します。 C++でプログラムを作っているのですけど、 プログラム中で<iostream.h>,<fstream.h>をインクルードしていて、コンパイルすると /usr/include/c++/3.2.2/backward/fstream.h:31 から include されたファイル中, stereo_draw.cpp:4 から: /usr/include/c++/3.2.2/backward/backward_warning.h:32:2: 警告: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. と言うエラーメッセージが出るのです(stereo_draw.cppは私の作ったソースファイル)。 英語が得意ではないので訳があやしいですが、 『このファイルは推奨してない、または古いヘッダーをインクルードしています。C++スタンダードセクション17.4.1.2中の32ヘッダーのいづれかを使うことを推めます。例えば<X.h>の代わりにC++インクルード用の<X>ヘッダーをインクルードするとか、非推奨の<strstream.h>の代わりに<sstream>を使うなど』 と言っているのではないかと思います。でも、セクション17.4.1.2の32個のヘッダーなんて知らないです。それに、Turboの時はこんなメッセージは出ませんでした。 これを解決する方法をどなたか知っていたら教えて下さい。

  • lunuxでコンパイル

    普段はリヌックスの環境を使っているのですが、ウィンドウズでしか動かないプログラムがあり、プログラムを実行するたびに、マシンを切り替えていて不便を感じています。 http://prefixspan-rel.sourceforge.jp/のC++のファイルをリヌックスでコンパイルしたいのですが、g++ prefixspan.cpp では In file included from /usr/include/c++/4.4/backward/strstream:47, from prefixspan.cpp:30: /usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. prefixspan.cpp: In function ‘int main(int, char**)’: prefixspan.cpp:492: error: ‘atoi’ was not declared in this scope となります。C++に関しては詳しくないのですが、これは直せるものなのでしょうか?

  • clock関数のコンパイルエラーで

    こんにちは。 C++プログラムの実行時間計測リスト #include<iostream.h> #include<time.h> int main(void){ clock_t start_time=clock(); int i; //ココから //計測したい処理を書く //ココまで cerr<<clock()-start_time<<"マイクロ秒"<<endl; return 0; } をRedHat9上でコンパイルしようとすると $gcc -o clock clock.cc /usr/include/c++/3.2.2/backward/iostream.h:31 から include されたファイル中, clock.cc:1 から: /usr/include/c++/3.2.2/backward/backward_warning.h:32:2: 警告: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. /tmp/ccoZe32a.o(.text+0x1c): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' /tmp/ccoZe32a.o(.text+0x3b): In function `main': : undefined reference to `std::cerr' /tmp/ccoZe32a.o(.text+0x40): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(long)' : collect2: ld はステータス 1 で終了しました となってしまいます。これはどうすればコンパイルできるようになるのでしょうか?

  • C++, strcpy の warning.

    VC2005 Express Edition を使ってます。 #include <iostream> #include <string> using namespace std; int main() {   char str[10] = "hello";   strcpy(str, "HELLO"); } ↑ こちらをコンパイルすると hello.cpp .\hello.cpp(8) : warning C4996: 'strcpy' was declared deprecated C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy' という警告が出るのはどうしてでしょうか? #include <string.h> も試したのですが同じ警告でした。

  • C++Builderでの警告

    C++Builderでユーザヘッダmy.hを インクルードしてコンパイルさせたところ [C++ 警告] my.h(8): W8058 ヘッダに初期化データが含まれているためプリコンパイルヘッダーを作成できない との警告がでました原因はなんでしょうか?

  • condefs.hはどこにあるの?

    #include <stdio.h> #include <windows.h> #ifdef __BORLANDC__ #include <condefs.h> #endif をヘッダに含むプログラムspitest.cppを無償コンパイラのボーランドC++5.5でコンパイルすると Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland spitest.cpp: エラー E2209 spitest.cpp 8: インクルードファイル 'condefs.h' をオープンできない *** 1 errors in Compile *** とエラーがでました。 どうしたらいいのでしょうか?

  • 複素数<complex.h>のErrorに関して

    初めて質問させて貰います。 質問するにあたり至らない点もあるかもしれませんが、その際は御指摘頂ければ随時訂正していきたいと考えています。 プログラムに関しては素人と考えてください。 複素数を使った計算プログラムを書きたく思い、色々と調べたところcomplexをincludeすれば複素数が定義できるという所まで調べられました。 早速調べたとおりにプログラムを書いてみたのですが、エラーが発生してしまいます。 エラーの示すことも、何故エラーがでたのかも分かりません。 よろしければ、御助言の方よろしくお願いします。 使用ソフト→ Microsoft Visual C++ 2008です。 以下プログラム(num001.cppで保存)→ #include<stdio.h> #include<complex.h> ~以下略 という感じでプログラムを書いたのですが、コンパイルしてみると、以下のようなエラーが発生してしまいます。 以下発生したエラーです→ num001.cpp C:\program\C++5.5\include\complex.h : warning C4819: ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。 データの損失を防ぐために、ファイルを Unicode 形式で保存してください。 C:\program\C++5.5\include\complex.h(3) : warning C4068: 不明なプラグマがありました。 C:\program\C++5.5\include\stdcomp.h : warning C4819: ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。 データの損失を防ぐために、ファイルを Unicode 形式で保存してください。 C:\program\C++5.5\include\compnent.h : warning C4819: ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。 データの損失を防ぐために、ファイルを Unicode 形式で保存してください。 C:\program\C++5.5\include\rw/stddefs.h : warning C4819: ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。 データの損失を防ぐために、ファイルを Unicode 形式で保存してください。 C:\program\C++5.5\include\rw/stddefs.h(3) : warning C4068: 不明なプラグマがありました。 C:\program\C++5.5\include\stdcomp.h : warning C4819: ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。 データの損失を防ぐために、ファイルを Unicode 形式で保存してください。 C:\program\C++5.5\include\rw/stdwind.h : warning C4819: ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。 データの損失を防ぐために、ファイルを Unicode 形式で保存してください。 C:\program\C++5.5\include\rw/stdwind.h(3) : warning C4068: 不明なプラグマがありました。 C:\program\C++5.5\include\rw/stdwind.h(208) :warning C4068: 不明なプラグマがありました。 C:\program\C++5.5\include\rw/stddefs.h(181) :warning C4068: 不明なプラグマがありました。 C:\VC\INCLUDE\xlocale(342) : warning C4530: C++ 例外処理を使っていますが、アンワインド セマンティクスは有効にはなりません。/EHsc を指定してください。 C:\program\C++5.5\include\complex.h(1488) : warning C4068: 不明なプラグマがありました。 よろしくお願いします。

  • Visual C++ 2008で<stdio.h>のインクルード文が使えない!?

    #include <stdio.h> int main(){ printf("hello!"); } で実行すると、 : warning C4627: '#include <stdio.h>': プリコンパイル済みヘッダーの使用を検索中にスキップされました ディレクティブを 'stdafx.h' に追加するか、プリコンパイル済みヘッダーをビルドし直します .\■■■.cpp(5) : fatal error C1010: プリコンパイル ヘッダーを検索中に不明な EOF が見つかりました。'#include "stdafx.h"' をソースに追加しましたか? と言ったエラーが起きてしまいます。 ちなみに、インクルードファイルらしき物を削除しまくった覚えがあります…。100%これが原因かと。 これが原因だとしたらどうすればいいんでしょうか? あと、DXライブラリが使えるように設定を変えたこともあります。 どこの何を変えたかは忘れてしまいましたけど。

  • #include <Windows.h>というヘッダファイルについて

    お早う御座います。 Cの初心者です、宜しくお願いします。 「#include <Windows.h>」というヘッダファイルはどのようなプログラムを書いたときにincludeしてやる必要があるのでしょうか。 宜しくお願いします。

専門家に質問してみよう