ホーム » 2020 » 2月 » 06

日別アーカイブ: 2020/02/06

2020年2月
 1
2345678
9101112131415
16171819202122
23242526272829

カテゴリー

アーカイブ

ブログ統計情報

  • 99,335 アクセス


NAS g++ で a.out が作成されない?

warning はあるが,エラーの表示はない状態まで修正して g++ .

Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ g++ t_calc.cpp -Wall
In file included from /volume1/public/C_Sync/GoogleD/Develop/_.SRC/_gcc/V2_FuncA.hxx:1:0,
                 from Calc_16.cpp:46,
                 from t_calc.cpp:29:
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx: In constructor 'vd2_arc::vd2_arc()':
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:28:9: warning: 'vd2_arc::tc' will be initialized after [-Wreorder]
  double tc ;
         ^~
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:27:9: warning:   'double vd2_arc::ts' [-Wreorder]
  double ts ;
         ^~
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:23:2: warning:   when initialized here [-Wreorder]
  vd2_arc () : lr(0) , tc(0) , ts(0) {}
  ^~~~~~~
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx: In function 'Vd2 get_point_pie(const Vd2&, const Vd2&, double, double)':
/volume1/public/C_Sync/GoogleD/Develop/_.SRC/__CPR_/v2_funca.hxx:263:6: warning: variable 'lm' set but not used [-Wunused-but-set-variable]
  Vd2 lm = (le-ls) / 2 ;
      ^~
In file included from t_calc.cpp:29:0:
Calc_16.cpp: In member function 'virtual int VarCnv::SetError(LPCTSTR, ...)':
Calc_16.cpp:1319:7: warning: variable 'cnt' set but not used [-Wunused-but-set-variable]
  int  cnt ;
       ^~~
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ ls
Calc_16.BAK  Calc_16.cpp  Calc_16.hpp  t_calc.BAK  t_calc.cpp  t_calc.dsp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ g++ t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ ls
Calc_16.BAK  Calc_16.cpp  Calc_16.hpp  t_calc.BAK  t_calc.cpp  t_calc.dsp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ ll
total 248
drwxrwxrwx+  2 Iwao users   4096 Feb  6 11:46 .
drwxrwxrwx+ 16 Iwao users   4096 Feb  6 10:18 ..
-rwxrwxrwx+  1 Iwao users 103036 Feb  6 11:45 Calc_16.BAK
-rwxrwxrwx+  1 Iwao users 103032 Feb  6 11:46 Calc_16.cpp
-rwxrwxrwx+  1 Iwao users  11608 Feb  5 18:53 Calc_16.hpp
-rwxrwxrwx+  1 Iwao users   2756 Feb  6 11:18 t_calc.BAK
-rwxrwxrwx+  1 Iwao users   2420 Feb  6 11:43 t_calc.cpp
-rwxrwxrwx+  1 Iwao users   4420 Feb  5 16:39 t_calc.dsp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ 

なのに a.out が作成されない.
Raspberry Pi で同様に動かすと

pi@raspberrypi:~/projects/t_calc $ g++ t_calc.cpp
In file included from t_calc.cpp:29:
Calc_16.cpp: In function ‘int ExpDel_Bracket1(TCHAR*, size_t, int, int, char)’:
Calc_16.cpp:2152:6: error: ‘_tcspbrk’ was not declared in this scope
  if (_tcspbrk(val,bracket)==NULL){ return FALSE ; } // ���ʂ����݂��Ȃ����͉������Ȃ�
      ^~~~~~~~
Calc_16.cpp:2152:6: note: suggested alternative: ‘wcspbrk’
  if (_tcspbrk(val,bracket)==NULL){ return FALSE ; } // ���ʂ����݂��Ȃ����͉������Ȃ�
      ^~~~~~~~
      wcspbrk
Calc_16.cpp:2161:21: error: ‘_tcsrchr’ was not declared in this scope
  LPTSTR equStartB = _tcsrchr(tmpLeft,startB) ; // �ŏ��� ')' �ɑΉ����� '(' �̈ʒu�����߂�
                     ^~~~~~~~
Calc_16.cpp:2161:21: note: suggested alternative: ‘_tcschr’
  LPTSTR equStartB = _tcsrchr(tmpLeft,startB) ; // �ŏ��� ')' �ɑΉ����� '(' �̈ʒu�����߂�
                     ^~~~~~~~
                     _tcschr
pi@raspberrypi:~/projects/t_calc $ 

どうも ShiftJIS のコメントが邪魔してかエラーが表示されてないだけみたい.
Raspberry Pi でコンパイルするとエラーが表示される
未定義となっているので正しく宣言して対応.


次は warning .

.../v2_funca.hxx:28:9: warning: 'vd2_arc::tc' will be initialized after [-Wreorder]      double tc ;
.../v2_funca.hxx:27:9: warning:   'double vd2_arc::ts' [-Wreorder]                       double ts ;
.../v2_funca.hxx:23:2: warning:   when initialized here [-Wreorder]                      vd2_arc () : lr(0) , tc(0) , ts(0) {}

これは,クラス内の変数の宣言と初期化の順番が異なる場合のものらしい.
もう一つの [-Wunused-but-set-variable] は戻り値を使用していないもの.

warning: variable 'lm' set but not used [-Wunused-but-set-variable]

変数を削除して対応.


前後するが 先日のツール で ShiftJIS のソースを UTF-8 に.

Iwao@DS116:~/gcc_test/Test/t_linux/t_calc$ cd test_sj/
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ ls
Calc_16.cpp  Calc_16.hpp  t_calc.BAK  t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ g++ t_calc.cpp -Wall
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ ll
total 132
drwxrwxrwx+ 2 Iwao users   4096 Feb  6 16:39 .
drwxrwxrwx+ 3 Iwao users   4096 Feb  6 16:38 ..
-rwxrwxrwx+ 1 Iwao users 103036 Feb  6 14:41 Calc_16.cpp
-rwxrwxrwx+ 1 Iwao users  11608 Feb  5 18:53 Calc_16.hpp
-rwxrwxrwx+ 1 Iwao users   1821 Feb  6 16:04 t_calc.BAK
-rwxrwxrwx+ 1 Iwao users   1841 Feb  6 16:39 t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ g++ t_calc.cpp -Wall -finput-charset=SJIS
cc1plus: error: conversion from SJIS to UTF-8 not supported by iconv
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ g++ t_calc.cpp -Wall
In file included from t_calc.cpp:27:0:
Calc_16.cpp: In function 'int ExpDel_Bracket1(TCHAR*, size_t, int, int, char)':
Calc_16.cpp:2152:26: error: '_tcspbrk' was not declared in this scope
  if (_tcspbrk(val,bracket)==NULL){ return FALSE ; } // 括弧が存在しない時は何もしない
                          ^
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$ ll
total 136
drwxrwxrwx+ 3 Iwao users   4096 Feb  6 16:46 .
drwxrwxrwx+ 3 Iwao users   4096 Feb  6 16:38 ..
-rwxrwxrwx+ 1 Iwao users 108716 Feb  6 14:41 Calc_16.cpp
-rwxrwxrwx+ 1 Iwao users  12170 Feb  5 18:53 Calc_16.hpp
drwxrwxrwx+ 2 Iwao users   4096 Feb  6 16:45 org
-rwxrwxrwx+ 1 Iwao users   1841 Feb  6 16:39 t_calc.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/t_calc/test_sj$

エラーが表示される.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.