ホーム » VC (ページ 7)

VC」カテゴリーアーカイブ

2025年7月
 12345
6789101112
13141516171819
20212223242526
2728293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 117,825 アクセス


C4244: ‘初期化中’: ‘INT_PTR’ から …

VC 2002 より前に作成した「ダイアログベース」のプロジェクトの場合 x64 対応に変更すると
XxxApp.cpp(73): warning C4244: ‘初期化中’: ‘INT_PTR’ から ‘int’ への変換です。データが失われる可能性があります。

生成されるスケルトンでは,アプリケーションクラスのダイアログの部分が次の様になっている.

	CFBXtoMDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK) 	{
	}
	else if (nResponse == IDCANCEL) {
	}

x86,x64 共に warning などを出なくするには,int となっている部分を INT_PTR に変更 する.

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

「MFC を使用しない」のエラー

’91 年に C で作成して,’95 年頃に C++ で書き直したコード.
その頃は MFC なしでも動作するようにコードを書いていた.
が,’06 頃の UNICODE 化で MFC に依存するようになってしまっている.
VC6 「プロジェクトの設定」-「MFC を使用しない」
main 関数だけ用意して,対象の cpp をインクルードしてビルドすると,

--------------------構成: t_calc - Win32 Debug--------------------
コンパイル中...
t_calc.cpp
リンク中...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) はすでに libcpd.lib(delop.obj) で定義されています
nafxcwd.lib(thrdcore.obj) : error LNK2001: 外部シンボル "__endthreadex" は未解決です
nafxcwd.lib(thrdcore.obj) : error LNK2001: 外部シンボル "__beginthreadex" は未解決です
C:\Temp\Debug\Calc\t_calc\Debug.060/t_calc.exe : fatal error LNK1120: 外部参照 2 が未解決です。
link.exe の実行エラー

t_calc.exe - エラー 4、警告 0

どこかで Afx.h など MFC のコードをインクルードしてしまっている.
インクルードを順に辿るとすぐ見つかるが,どう修正するか悩むところ.
MFC を必要とする場合は今まで通りで,不要な場合は新しいコードに切り替えるか?

#ifdef	 _MFC_VER
#include <Afx.h>
#else
#include "_s_func.hxx"
#endif

ある程度必要なコードは特定できたがまだ書き直してないコードもありそう.


_MFC_VER で切り替えようと思ったが,コンソール AP ではうまく機能しない.
How to detect “Use MFC” in preprocessor
_MFC_VER は Afx.h の中で間接的(AfxVer_.h)に定義されている.
使えるのは _AFXDLL のみ?


次の様な感じ?

#ifdef	 _MSC_VER
#ifdef	 _AFXDLL
#include <Afx.h>
#else
#include <Windows.h>
#endif
#endif

2020/02/14
ヘッダファイルで CString などを使用しているコードの部分は

#ifdef	 _MFC_VER
CString  ChangeString  (LPCTSTR str) ;
#endif

2020/09/25
コンソール AP での define

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

VC /LARGEADDRESSAWARE

64 ビットバイナリの作成に関して調べていて /LARGEADDRESSAWARE を見つけたのでメモ.
/LARGEADDRESSAWARE (大きいアドレスの処理)
これを有効にすると 64 ビット環境で 2 GB を超えるメモリを利用できるみたい.
プロジェクトの「プロパティ」-「構成プロパティ」-「リンカ」-「システム」-「大きいサイズのアドレス」
「プロパティ」-「構成プロパティ」-「リンカ」-「システム」-「大きいサイズのアドレス」


次の様なコードで動作を確認.

#include	<iostream>
#include	"memstat.hxx"
#include	"gettickc.hxx"

int		_tmain	(int argc, TCHAR* argv[])
{
	u_32	free_M = 0 ;
	{
		MemoryStatus	ms ;
		std::tout << long(ms.GetPhysFree()/1024/1024) << std::endl ;
		free_M = u_32(ms.GetPhysFree ()/1024/1024) ;
		}
	{
		std::vector <void*>	memAry(1024,(void*)NULL) ;
		u_32	index =0 ;
		u_32	allocTotal = 0 ;
		u_32	allocSize = free_M/2 ;
		u_32	ngCount = 0 ;
		for (index=0 ; index<free_M && ngCount<10 ; ) {
			if (allocSize == 0)	{	break ;		}
			void*	pAlloc = calloc(allocSize,1024*1024) ;
			if (pAlloc != NULL) {
				allocTotal += allocSize ;
				}
			else {
				allocSize /= 2 ;
				ngCount++ ;
				continue ;
				}
			MemoryStatus	ms ;
			std::tout  <<  allocSize  <<  _T("\t") << allocTotal << _T("\t") << long(ms.GetPhysFree()/1024/1024) << std::endl ;
			free_M = u_32(ms.GetPhysFree ()/1024/1024) ;
			memAry.at(index) = pAlloc ;
			::Sleep_ms(1000) ;
			index++ ;
			if (ngCount > 100)	{	break ;		}
			}
		for (index=0 ; index<free_M ; index++) {
			void*	pAlloc = memAry.at(index) ;
			free(pAlloc) ;
			}
		}
	return 0;
	}

/LARGEADDRESSAWARE を有効にすることで 4 GB まで確保できている.

Microsoft Windows [Version 10.0.18362.592]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_m_stat\release.080\T_m_stat.exe
3845
961     961     3844
480     1441    3847
240     1681    3845
120     1801    3845
120     1921    3845
60      1981    3837
15      1996    3836
7       2003    3830
7       2010    3830
7       2017    3831
3       2020    3826
3       2023    3826

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_physf\release.080\T_PhysF.exe
3814
1907    1907    3814
953     2860    3801
476     3336    3799
238     3574    3799
119     3693    3800
119     3812    3790
119     3931    3789
59      3990    3788
29      4019    3792
14      4033    3787
14      4047    3787
7       4054    3787
7       4061    3786
3       4064    3778
3       4067    3781
3       4070    3781
3       4073    3781

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\Iwao>

以下は,デバッグ版とリリース版での違い.

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_physf\debug.080\T_PhysF.exe
4606
1151    1151    3461
1151    2302    2300
575     2877    1713
575     3452    1188
287     3739    915
143     3882    758
71      3953    671
35      3988    629
17      4005    600
17      4022    582
17      4039    554
8       4047    566
8       4055    554
8       4063    539
4       4067    527

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_physf\release.080\T_PhysF.exe
4406
1101    1101    4394
1101    2202    4401
550     2752    4393
550     3302    4403
275     3577    4403
137     3714    4403
68      3782    4403
68      3850    4403
68      3918    4402
34      3952    4502
34      3986    4503
17      4003    4501
17      4020    4502
17      4037    4499
17      4054    4498
8       4062    4499
8       4070    4498
4       4074    4497

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\Iwao>

デバッグ版では空きメモリが減っている


2020/02/05
(VS)\VC\bin\EditBin.exe でも同様の設定ができるみたい.
EDITBIN リファレンス
“C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\editbin.exe/LARGEADDRESSAWARE C:\Users\Iwao\AppData\Local\Temp\i_Tools.tmp\CopyNewF\20200204\T_Phys_L.exe


2020/02/14
確保したメモリのアドレスを表示する様にしてみた.

Microsoft Windows [Version 10.0.18362.657]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>\\TestXP\C_Temp\TestCPP\T_mem\T_m_stat\Release.060\T_m_s_2.exe
2030
1015    1015    2030    0000000000878020
507     1522    2030    000000003ff83020
253     1775    2030    000000005fa90020
126     1901    2029    00000000772a7020
63      1964    2029    000000006f7a6020
15      1979    1950    00000000736b7020
15      1994    1947    0000000074f65020
7       2001    1949    0000000075e73020
7       2008    1949    000000007f0b6020
3       2011    1946    0000000074868020
3       2014    2007    0000000074b7d020
3       2017    2009    000000007658e020
3       2020    2010    0000000076890020
3       2023    2011    000000007f7cb020
3       2026    2012    000000007fada020
1       2027    2013    00000000005f2020
1       2028    2013    00000000745c8020
1       2029    2013    0000000076e05020
1       2030    2013    0000000076f14020

abnormal program termination

C:\Users\Iwao>\\TestXP\C_Temp\TestCPP\T_mem\T_m_stat\Release.060\T_m_s_4.exe
1935
967     967     1935    000000000087a020
967     1934    1996    000000007fff7020
967     2901    1996    ffffffffbc70c020
483     3384    1995    000000003cf8e020
241     3625    1996    000000005b293020
120     3745    1997    000000006a3a8020
120     3865    1994    00000000772aa020
60      3925    1996    fffffffff8e1d020
30      3955    1996    0000000071bbc020
30      3985    1996    fffffffffca2c020
15      4000    1874    0000000074f66020
15      4015    1832    000000007eab8020
15      4030    1996    fffffffffe838020
7       4037    2102    00000000739cd020
7       4044    2139    0000000075e7e020
3       4047    2181    00000000740dc020
3       4050    2254    00000000743ed020
3       4053    2255    0000000074868020
3       4056    2255    0000000074b76020
3       4059    2261    0000000076583020
3       4062    2372    000000007689f020
3       4065    2371    000000007f9c0020
3       4068    2371    000000007fcd5020
3       4071    2371    ffffffffff743020
3       4074    2372    ffffffffffa50020
1       4075    2372    00000000006ec020
1       4076    2296    0000000076e04020
1       4077    2296    0000000076f19020

abnormal program termination

C:\Users\Iwao>

/LARGEADDRESSAWARE を有効にした時の確保したメモリのアドレス

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

VC 6 C2059 C2091 C2809 C2954

2001/11 作成のプロジェクトをビルドしたらよくわからないエラー.

--------------------構成: MsgStCon - Win32 Debug--------------------
コンパイル中...
MsgStCon.cpp
c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2059: 構文エラー : 'string'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: 関数は関数を返せません。
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' に仮引数リストがありません。
c:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: テンプレートの定義はネストできません。
cl.exe の実行エラー

MsgStCon.obj - エラー 4、警告 0

C2059 C2091 C2809 C2954


ソースの先頭付近に #include <memory> を追加.

#include	"StdAfx.h"
#include	"MsgStCon.h"

#include	<memory>	//	① OK
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include	<memory>	//	② NG

//	...

②の位置では現象は変わらず.①の位置に追加する必要がある.


2023/03/24
error C2061 , C2091 , C2809 , C2556

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

漢字を含むソースのテスト

’90 年代前半の頃は JIS と シフトJIS のソースを扱っていた.
そのプロジェクトの最初の頃は,ターゲット環境のみでソースを管理していた.
0x1c 0x2d 漢字 0x1c 0x2e の形式.wiki 漢字シフトコード
途中からソース管理は PC-9801DA などに移行してシフトJIS になった.
ターゲット環境に移す時,ソースのコピーとシフトJIS から JIS への変換を行っていた.


Linux 環境を意識し始めてから新規に書いた共通のコードは 7 ビットの範囲にしている.
Windows AP であれば rc ファイルの STRINGTABLE が使用できるが,これにあたるものをどうするか?
まず一番簡単な方法の漢字を含むソースでの動作をテストしてみた.
この中の ccc(const char* s) の部分はまだ暫定的なコードで,登録されたテーブルから対応する JPN を求めるもの.

#include	<clocale>
#include	<iostream>
#include	"i_define.hxx"
#include	"_tdefine.hxx"
#include	"ccc_mlg.hxx"

bool	test	(void)
{
	ccc_mlg*	cm = ::get_ccc_mlg() ;
	{
		ccc_mlg_1	cm_1 ;	cm_1.Name = _T("Name_1") ;	cm_1.JPN = _T("名称 1") ;
		ccc_mlg_1	cm_2 ;	cm_2.Name = _T("Name_2") ;	cm_2.JPN = _T("名称 2") ;
		ccc_mlg_1	cm_3 ;	cm_3.Name = _T("Name_3") ;	cm_3.JPN = _T("名称 3") ;
		ccc_mlg_1	cm_4 ;	cm_4.Name = _T("Name_4") ;	cm_4.JPN = _T("名称 4") ;
		ccc_mlg_1	cm_5 ;	cm_5.Name = _T("Name_5") ;	cm_5.JPN = _T("名称 5") ;
		cm->push_back(cm_1) ;
		cm->push_back(cm_2) ;
		cm->push_back(cm_3) ;
		cm->push_back(cm_4) ;
		cm->push_back(cm_5) ;
		}
	std::tout << ccc("Name_3") << std::endl ;
	return	true ;
	}

int _tmain(int argc, TCHAR* argv[])
{
	_tsetlocale(LC_ALL,_T("")) ;
	test() ;
	return 0 ;
	}

gcc 漢字 shiftjis」で検索すると -finput-charset で文字コードを指定できるとある.

pi@raspberrypi:~/projects/cc_ml_1 $ g++ cc_ml_1.cpp 
pi@raspberrypi:~/projects/cc_ml_1 $ ./a.out 
���� 3
pi@raspberrypi:~/projects/cc_ml_1 $ g++ -finput-charset=SJIS-WIN cc_ml_1.cpp 
pi@raspberrypi:~/projects/cc_ml_1 $ ./a.out 
名称 3
pi@raspberrypi:~/projects/cc_ml_1 $ 

g++ -finput-charset=SJIS-WIN
-finput-charset=SJIS ではよくわからないエラーになる.
g++ -finput-charset=SJIS
cp932 でも良さそう.


Synology NAS DS116 は g++ の-finput-charset の指定では変換できないみたい.

Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ cc_ml_1.cpp -Wall
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ ll
total 72
drwxrwxrwx+  3 Iwao users  4096 Jan 16 22:01 .
drwxrwxrwx+ 10 Iwao users  4096 Jan 16 21:36 ..
-rwxrwxrwx   1 Iwao users 50452 Jan 16 22:01 a.out
drwxrwxrwx+  2 Iwao users  4096 Jan 16 21:53 bak
-rwxrwxrwx+  1 Iwao users  2001 Jan 16 22:00 cc_ml_1.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ ./a.out
 3
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ uconv -f sjis cc_ml_1.cpp > dd.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ dd.cpp
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ ./a.out
名称 3
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ -finput-charset=SJIS cc_ml_1.cpp
cc1plus: error: conversion from SJIS to UTF-8 not supported by iconv
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ g++ -finput-charset=sjis cc_ml_1.cpp
cc1plus: error: conversion from sjis to UTF-8 not supported by iconv
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$ iconv
-sh: iconv: command not found
Iwao@DS116:~/gcc_test/Test/t_linux/cc_ml_1$
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Windows , Linux 共通の c++ コード

3 年位前から,少しずつ Windows や Linux に依存しない c++ のコードを書く様にしている.
ソースファイルの文字コードと改行コードは 7 ビットの範囲で crlf にしている.
.sh などは lf でないとうまくない.
html などの場合は UTF-8 .
扱うファイル名も 7 ビットの範囲に限定している.
これで UI を伴わない範囲ではほぼうまく機能している.
次のページからのリンク先で WebGL を使用したサーバのコードはソースレベルで互換性あり.
https://itl.mydns.jp/i_Tools/

他に Windows 専用のコードとの区別のため,ファイル名を小文字に.
これは Linux では大文字,小文字が区別されるため.


今回既存の AP ドキュメントを扱うことに.
Windows でいう「シフト JIS」と「UNICODE」のテキストファイル.
他に UTF-8 のファイルもあるが対応する必要性は未定.
UTF-8 ファイルは Windows のコードでは書いているが,テスト用に存在するのみ.


今までの Windows のコード(tstrmbwc.hxx)では _T や _UNICODE の有無でうまく機能している.
読み込んだ時に _UNICODE の有無でそれぞれの文字コードで保持すればほぼ OK .
「ほぼ」というのは「㎥」の様にシフト JIS にない文字は失われてしまうため.
他にもサロゲートペアにはうまく対応できていない.


Linux でも同様に考えると,読み込んだ時に UTF-8 にすれば良さそう.
wchar_t もあるみたいだが今の時点では考慮しないことにする.
と,思ってテスト用のコードを書いてみたがうまく動作しない.
恐らく変換関連の考え方が理解できていないため.


2020/02 「文字コードを変更してコピー」するツール
https://i–tools.blogspot.com/2020/02/copycc202001.html
「文字コードを変換してコピー」するツール

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

GLUT でテクスチャ表示

今度はテクスチャ.次の様なコードで面に貼り付け.

#include	"glut_cg.hxx"
#include	"gonsprmt.hxx"
#include	"i_dib_f.hxx"

i_DIB	tex_01 ;

int	main(int argc, char* argv[])
{
	{
		tstring	test_bmp = _T("./Tex01.bmp") ;
		//     	test_bmp = _T("/run/user/1000/gvfs/smb-share:server=ds116.local,share=web/i_Tools/Doc/blog/3D_Data/Tex01.bmp") ;
		#ifdef  _MSC_VER
		      	test_bmp = _T("//DS116/web/i_Tools/Doc/blog/3D_Data/Tex01.bmp") ;
		#endif
		tex_01 = ::DIB_Load(test_bmp.c_str()) ;
		}
	{
		GonsA	gnsa ;
		{
			Gons1	box = ::Gons_Box(Vd3(5,0,5)) ;
			box.SetColor(0xffffff) ;
			gnsa.push_back(box) ;
			}
		::set_GonsA(gnsa) ;
		::set_Extent(::GonsA_GetExtent(gnsa)) ;
		{
			C_glut*	gm = ::get_c_glut() ;
			gm->BG     = Vd4(0.9) ;
			gm->EP     = Vd3(0,-10,0) ;
			}
		}
	::glutInitWindowPosition(200,100) ;
	::glutInitWindowSize	(600,600) ;
	::glutInitDisplayMode	(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) ;
	::glutInit           	(&argc,argv) ;
	::glutCreateWindow  	(argv[0]) ;
	::glutReshapeFunc   	(cv_resize) ;
	::glutDisplayFunc   	(cg_display) ;
	::glutKeyboardFunc  	(cv_keyboard) ;
	::glutMouseFunc   	(cv_mouse) ;
	::glutMotionFunc  	(cv_motion) ;
	::cv_init       	() ;
	{
		::glPixelStorei(GL_UNPACK_ALIGNMENT,1) ;
		::glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,tex_01.GetWidth(),tex_01.GetHeight(),0,GL_RGB,GL_UNSIGNED_BYTE,tex_01.GetP_Bits()) ;
		::glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) ;
		::glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST) ;
		::glEnable(GL_TEXTURE_2D) ;
		}
	::glutMainLoop   	() ;
	return	0 ;
	}

::glTexImage2D の指定と Tex01.bmp の形式が合っていないため
GLUT でテクスチャ表示 間違った GL_RGB の指定でずれている
32 ビット色の画像なので ::glTexImage2D の GL_RGB を GL_RGBA に.
GLUT でのテスクチャ表示 R と B  が合っていない
色の順番が違うので ::glTexImage2D を見ると GL_BGRA_EXT があったのでこれを指定.
GLUT でテクスチャ表示 GL_BGRA_EXT を指定

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

OpenGL 線を表示すると途切れる?

線の配列から連続線に変更して OpenGL で表示すると途切れた表示になってしまった.
OpenGL GL_LINES と GL_LINE_STRIP
線分として表示していた時のコード

	for (size_t lIndex=0 ; lIndex<lins.size() ; lIndex++) {
		Vl2	ln = lins[lIndex] ;
		Vd3	p0 = ::Vx_get(pnts,ln.x) ;
		Vd3	p1 = ::Vx_get(pnts,ln.y) ;
		::glBegin(GL_LINES) ;
		{
			::glVertex(p0....) ;
			::glVertex(p1....) ;
			}
		::glEnd() ;
		}

途切れてしまったコード

	for (size_t lIndex=0 ; lIndex<lins.size() ; lIndex++) {
		v_long	lin = lins[lIndex] ;
		::glBegin(GL_LINES) ;
	//	::glBegin(GL_LINE_STRIP) ;
		for (size_t vIndex=0 ; vIndex<lin.size() ; vIndex++) {
			long	ln = lin[vIndex] ;
			Vd3	pt = ::Vx_get(pnts,ln) ;
			::glVertex(pt....) ;
			}
		::glEnd() ;
		}

原因は glBegin の指定が GL_LINES のままだった.
GL_LINE_STRIP に修正して意図した表示になった.
OpenGL Programming Guide
Chapter 2 State Management and Drawing Geometric Objects

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

VS 2019 Raspberry Pi への接続で…

VS 2019 の「オプション」-「クロスプラットフォーム」-…-「リモートヘッダー…」の「更新」を選択すると,
エラーが発生しました。Could not connect to the remote system or the connection was lost。詳細については、C:\Users\Iwao\AppData\Local\Temp\vslinux_header_update_log.txt を参照してください。トラブルシューティングについては、https://aka.ms/AA23jat をご覧ください。
「InteliSense 用のヘッダーのダウンロードおよび更新」でエラー
SSH コマンドで接続しようとするとやはり接続できない.IP では可能.

Microsoft Windows [Version 10.0.18362.418]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>ssh -l pi raspberrypi
ssh: Could not resolve hostname raspberrypi: \202\273\202\314\202\346\202\244\202\310\203z\203X\203g\202\315\225s\226\276\202\305\202\267\201B

C:\Users\Iwao>ssh -l pi 192.168.1.36
pi@192.168.1.36's password:
Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Nov 12 17:04:32 2019

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $

ちょっとわからないので,IP での接続を追加して対応.
IP で「リモートシステムへの接続」を追加

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

UWP アプリ

2016/03 に試してうまく動作しなかった UWP アプリ.
T90Chi VS2015 UWP 起動
一度起動するがすぐにエラーメッセージ.
—————————
Microsoft Visual Studio
—————————
Windows ストア アプリ ‘5a7750b3-af94-47d7-a064-b9adc49f8813_7r65t4tynye04!App’ をアクティブにできません。アクティベーション要求がエラー ‘操作はサポートされていません。不明なエラー: 0x80040904’ で失敗しました。
この問題のトラブルシューティングについては、ヘルプを参照してください。
—————————
OK ヘルプ
—————————
T90Chi VS2015 UWP 起動後エラー


「そんなもん」と思い触らないでいたが,DirectX があったので今の開発機で試してみた.
するとうまく動作する.
Z170S0 で UWP アプリの起動
どこかの設定が違うのだろうか?それともライセンスの関係?

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

VC Linux でのデバッグ

単純な「Linux ターミナル」の「コンソール AP」であれば,Windows コンソール AP と同様にデバッグできる.
出力は VS の「Linux コンソールウィンドウ」.
VC Linux コンソール AP のデバッグ


GLUT を使用したデバッグはこの方法ではできない?
::glutInit(&argc, argv); で抜けてしまう.
Linux 上で .out を起動しておいて VS の「デバッグ」-「プロセスにアタッチ」.
「接続の種類」を「SSH」にして「接続先」を Linux 環境に.
VC Linux デバッグ対象の .out にアタッチ
「使用可能なプロセス」が更新されるのでデバッグ対象の .out を選択して「アタッチ」でデバッグできる.

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

VC Linux で GLUT

GLUT を使用したコード
ビルドするとリンクでのエラーとなってしまう.

1>------ ビルド開始: プロジェクト: T_GL2, 構成: Debug x64 ------
1>ソースを検証します
1>リモートでソースを 'fedora' にコピーします
1>アーキテクチャを検証します
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.targets(184,5): warning : 配置で使用されるリモート システムに互換性のないプラットフォーム アーキテクチャ ('x64'、'ARM') があります。
1>アーキテクチャを検証します
1>リモート ビルドを開始しています
1>ソースをコンパイルします:
1>オブジェクトをリンクしています
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/obj/x64/Debug/main.o: in function `idle()':
1>D:\Document\VS\VS\2019\T_Linux\T_GL2\main.cpp(51): error : undefined reference to `glutPostRedisplay'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/obj/x64/Debug/main.o: in function `display()':
1>D:\Document\VS\VS\2019\T_Linux\T_GL2\main.cpp(56): error : undefined reference to `glClear'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:63: undefined reference to `glMatrixMode'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:64: undefined reference to `glLoadIdentity'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:65: undefined reference to `gluLookAt'
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:67: undefined reference to `glColor3d'
...
1>/usr/bin/ld : error : /home/Iwao/projects/T_GL2/main.cpp:165: undefined reference to `glutMainLoop'
1>collect2 : error : エラー: ld はステータス 1 で終了しました
1>プロジェクト "T_GL2.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

コマンドでの -l オプションにあたる指定が足りないため.
「リンカー」-「コマンドライン」-「追加のオプション」に以下を追加.
-lglut -lGL -lGLU
-l オプション
GLUT を使用した .out

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

VC Linux の include 設定

VC Linux プロジェクトの include 設定
次のようなコードをビルドするのに include の設定がわからなかった.

#include	<cstdio>
#include	"gettickc.hxx"

int main()
{
	printf("VC 2019 hello !\n");
	for (long index = 0; index < 100; index++) {
		::Sleep_ms(100);
		printf("hello \t");
		fflush(stdout);
		if (index%5 == 4)	{
			printf("\n");
			}
		}
	printf("VC 2019 hello !\n");
	return 0;
	}

VC Linux プロジェクトの 「インクルードディレクトリ」設定


MFC のプロジェクトなどであれば,次の所で指定している.
C:\Users\Iwao\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.x64.user.props
共通のインクルードディレクトリは,次の様なもの.
\\DevS\Documents\Develop\_.SRC\__CPR_;\\DevS\Documents\Develop\_.SRC\__Iwao;…


ソース内で次の様に指定してもエラーに.
#include “\\DevS\Documents\Develop\_.SRC\__CPR_\i_define.hxx”

1>main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Application Type\Linux\1.0\Linux.targets(412,5): error : g++ がコード 1 で終了しました。詳細については、出力ウィンドウでビルド出力をご確認ください (注: 出力ウィンドウで詳細を確認するには、ツール オプションでビルド出力の詳細度を変更する必要があります)。
1>プロジェクト "ConsoleApplication2.vcxproj" のビルドが終了しました -- 失敗。

他に #include “//devs/documents/develop/_.src/__cpr_/i_define.hxx” としてみたが変わらず.


Raspberry Pi でビルドするともう少しわかりやすいエラーの表示になった.

1>main.cpp
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error : \\DevS\Documents\Develop\_.SRC\__CPR_\i_define.hxx: そのようなファイルやディレクトリはありません
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error :  #include "\\DevS\Documents\Develop\_.SRC\__CPR_\i_define.hxx"
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error :           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1>D:\Document\VS\VS\2019\T_Linux\ConsoleApplication2\main.cpp(18,10): error : compilation terminated.
1>プロジェクト "ConsoleApplication2.vcxproj" のビルドが終了しました -- 失敗。

いろいろやって,次の様に指定することでうまくいった.
#include “/mnt/_.src/__cpr_/i_define.hxx”
プロジェクトの設定で次のものを指定することでビルドできることを確認.
/mnt/_.src/__CPR_;/mnt/_.src/__Iwao;/mnt/_.src/__Mlt_;/mnt/_.src/_gcc;/mnt/_.src/Test


/mnt/_.src はマウントしている.
Linux から Windows 環境への接続
g++ インクルードパスの設定

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

Fedora への ssh 接続

Fedora での SSH 接続の有効化
Fedora では「設定」-「共有」-「リモートログイン」がそれにあたる.
VS でのリモートの設定 は「ツール」-「オプション」で開いた「クロスプラットフォーム」にある.
リモート環境の追加
プロジェクトの設定も必要で「構成プロパティ」-「全般」の「リモートビルドマシン」.
リモートビルドマシンの設定
これが合っていないとビルドエラーになる.

1>------ ビルド開始: プロジェクト: ConsoleApplication1, 構成: Release x64 ------
1>Validating sources
1>Copying sources remotely to '192.168.1.34'
1>Validating architecture
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Application Type\Linux\1.0\Linux.targets(151,5): error : Current project architecture 'x64' is incompatible with the remote system architecture 'ARM' ('ARM'). Please switch the project architecture to 'ARM' in Configuration Manager.
1>プロジェクト "ConsoleApplication1.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

Ubuntu では ssh サーバが入っていないみたいで次のコマンドでインストール.
$ sudo apt install openssh-server
何故か password を受け付けない?
Win10 19h1 のコマンドプロンプトで次の様にしても接続できない.

C:\Users\Iwao\AppData\Local\Temp>ssh -l Iwao -p 22 192.168.1.39
Iwao@192.168.1.39's password:
Permission denied, please try again.
Iwao@192.168.1.39's password:

何か他の設定が足りないのか?


設定関連のドキュメントは次の所にあった.
Linux ワークロードのダウンロード、インストール、セットアップ

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

VC 2017 Linux プロジェクト

VC 2017 を弄っていたら,Linux のプロジェクトの作成が可能になっていたので試してみた.
どのタイミングだったか忘れたが,SSH 接続が必要になる.


今まで設定してある Raspberry Pi に接続してみた.
Raspberry Pi  SSH 設定
Raspberry Pi 側の設定は「Raspberry Pi の設定」-「インターフェイス」にある.


ビルド時に使用する include は以下にコピーされている.これは Raspberry Pi の /user/include と同じ内容?
C:\Users\Iwao\AppData\Local\Microsoft\Linux\HeaderCache\1.0\-1277036696\usr\include
Raspberry Pi の /user/include のコピー
ビルドして出来上がった .out は /home/pi/projects/…/bin/ARM/Release にある.
Raspberry Pi /home/pi/projects/

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

LNK1143 : ファイルが無効であるか…

VC 6 で 2017/04 頃のプロジェクトをビルドすると,
fatal error LNK1143: ファイルが無効であるか、 または壊れています: COMDAT セクション 0xFFFF8000 のシンボルがありません。


--------------------構成: GLSmth - Win32 Release--------------------
GLSm.exe - エラー 0、警告 0
--------------------構成: GLSmth - Win32 Debug--------------------
GLSm.exe - エラー 0、警告 0
--------------------構成: T_tjs_1 - Win32 Release--------------------
T_tjs_1.exe - エラー 0、警告 0
--------------------構成: T_tjs_1 - Win32 Debug--------------------
T_tjs_1.exe - エラー 0、警告 0
--------------------構成: T_tjs_2 - Win32 Release--------------------
T_tjs_2.exe - エラー 0、警告 0
--------------------構成: T_tjs_2 - Win32 Debug--------------------
T_tjs_2.exe - エラー 0、警告 0
--------------------構成: T_tjs_3 - Win32 Release--------------------
T_tjs_3.exe - エラー 0、警告 0
--------------------構成: T_tjs_3 - Win32 Debug--------------------
T_tjs_3.exe - エラー 0、警告 0
--------------------構成: T_tjs_4 - Win32 Release--------------------
T_tjs_4.exe - エラー 0、警告 0
--------------------構成: T_tjs_4 - Win32 Debug--------------------
コンパイル中...
T_tjs_4.cpp
...
c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(439) : fatal error C1076: コンパイラの制限 : ヒープの領域を使い果たしました; 上限を設定するために /Zm オプションを使用してください。
        c:\program files\microsoft visual studio\vc98\include\xlocmon(106): クラス テンプレートのメンバ関数 'void __thiscall CArray::SetAtGrow(int,class Material)' のコンパイル中
cl.exe の実行エラー
T_tjs_4.exe - エラー 1、警告 0
--------------------構成: thrjs_3d - Win32 Release--------------------
thrjs_3d.exe - エラー 0、警告 0
--------------------構成: thrjs_3d - Win32 Debug--------------------
thrjs_3d.exe - エラー 0、警告 0
--------------------構成: thrjs_mb - Win32 Release--------------------
thrjs_mb.exe - エラー 0、警告 0
--------------------構成: thrjs_mb - Win32 Debug--------------------
リンク中...
thrjs_mb.obj : fatal error LNK1143: ファイルが無効であるか、 または壊れています: COMDAT セクション 0xFFFF8000 のシンボルがありません。
link.exe の実行エラー

thrjs_mb.exe - エラー 1、警告 0
--------------------構成: thrjs_mk - Win32 Release--------------------
thrjs_mk.exe - エラー 0、警告 0
--------------------構成: thrjs_mk - Win32 Debug--------------------
thrjs_mk.exe - エラー 0、警告 0

最初 C1076 のエラーがあったが,この対応には /Zm150 を追加
GLSmth 以外のプロジェクトは,コンソール AP .
threejs 内のプロジェクト
VC 7 や 8 では問題なくビルドできる.


これらのプロジェクトでは main() を含む cpp に他の cpp をインクルードしている.
VC 6 では,ある大きさを超える cpp のコンパイルで正しく obj が作成できないみたい.
出来上がっている obj のファイルサイズは 21 MB 位.
main を含むソースを分割することで対応可能.

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

コンパイルオプション -Dname=…

コンパイル時のオプションで -DVER=2019.09 の様な指定を使いたくなったので調べてみた.
コードは次のようなもの.

#include	<iostream>
#include	<iomanip>

#ifndef	Test_Ver_F
#define	Test_Ver_F  2019.0902
#endif

int	main	(int argc,   char* argv[])
{
	{
		std::cout                            	<< Test_Ver_F  << std::endl ;
		std::cout <<  std::setprecision(20)  	<< Test_Ver_F  << std::endl ;
		}
	return	0 ;
	}
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ g++ t_ccsw_d.cpp 
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ ./a.out 
2019.09
2019.0902000000000953
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ g++ t_ccsw_d.cpp -DTest_Ver_F=2019.0902
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ ./a.out 
2019.09
2019.0902000000000953
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ g++ t_ccsw_d.cpp -DTest_Ver_F="2019.0902"
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ ./a.out 
2019.09
2019.0902000000000953
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ g++ t_ccsw_d.cpp -DTest_Ver_F=\"2019.0902\"
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ ./a.out 
2019.0902
2019.0902
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ g++ t_ccsw_d.cpp -DTest_Ver_F=\"2019.09.02\"
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ ./a.out 
2019.09.02
2019.09.02
pi@raspberrypi:~/Documents/test_gcc/t_ccsw_d $ 

g++ t_ccsw_d.cpp -DTest_Ver_F=2019.0902
2019.0902 の様な浮動小数点の指定は特に変わった所はない.
但し浮動小数点による誤差などは考慮が必要.
文字列として扱いたいときは \” で括ればよい.

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

xml の読込み – 3

2019/01 に書いた xml の読込み で,属性が次の様になっている場合うまく処理できないバグがあった.
attr=’”a” “b”‘
他にも !DOCTYPE があるとうまく処理できていなかった.
また,そのデータの出力(Save_xml)も attr=””a” “b”” となってうまくなかった.
xml 読込みバグ データ
parsexml.hxx
xml_out.hxx


https://jml.mish.work/index.php/cpp/xml.html

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

VC 2015 x64 プロジェクトで C1128

FBX SDK を使用した VC 2015 x86 プロジェクトを x64 にしたら,
—— ビルド開始: プロジェクト:FBXtoM, 構成:Debug x64 ——
FBXtoM.cpp
FBXtoM.cpp(73): warning C4244: ‘初期化中’: ‘INT_PTR’ から ‘int’ への変換です。データが失われる可能性があります。
FBXtoMDg.cpp
E:\…\FBXtoM\FBXtoMDg.cpp : fatal error C1128: セクションの数がオブジェクト ファイル形式の制限を超えています: /bigobj と共にコンパイルしてください


Release 版では C4244 の warning は出るがビルドできる.
C4244 はアプリケーションクラスの dlg.DoModal の戻り値を int から INT_PTR に
C1128 の対応は x64 Debug 版の「プロパティ」-「C/C++」-「コマンドライン」-「追加のオプション」に /bigobj を追加.
VC 2015  x64 Debug 版のコンパイルオプション /bigobj

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

VC 2015 Release.exe で 0xC0000005

今まで VC 2013 だったプロジェクトを VC 2015 に.
Release 版を実行するとエラーに.
0x006F3947 で例外がスローされました (FBXtoM.exe 内): 0xC0000005: 場所 0xFFFFFFFF の読み取り中にアクセス違反が発生しました
この例外のハンドラーがある場合は、プログラムを安全に続行できます。
0xC0000005: 場所 0xFFFFFFFF の読み取り中にアクセス違反が発生しました
Debug 版では問題ない.また,VC 2013 Release 版も通る.
変数 bp がおかしくなっているっぽいがよくわからない.


このプロジェクトは FBX SDK を使用しているため,VC が限定される.
そのため,この部分の単体テスト用のプロジェクトがあったのでそれを VC 6 から順にビルド.
やはり,VC 2015 では実行時エラーとなる.VC 2017 は通る.
検索すると「VC 2015 の問題」と思われる情報があった.
Visual Studio 2015 および Visual C++ 2017 のリンク時のコード生成における最適化の不具合について
今使っている VS 2017 のバージョンは 15.9.13 .


単体テストプロジェクトで,書かれていた回避策を試したが効果なし?
コンパイルの「最適化」で「実行速度の最大化(/O2)」を「サイズの最小化(/O1)」に変更して通る様にはなった.
VC 2015 コンパイル時の最適化の指定


次の様に bp を求める部分を使用する直前に移動して対応.

	if (0<=lv && 0<=bv) {
	//	Vd3	bp = lp-be.lll() ;
		bi->SetLV1(bIndex,lv) ;
		bi->SetLV2(bIndex,lv) ;
		bi->SetLP1(::ToP3(lp)) ;
		bi->SetLP2(::ToP3(lp)) ;
		bi->SetBV1(bv) ;
		bi->SetBV2(bv) ;
		Vd3	bp = lp-be.lll() ;
		bi->SetBP1(::ToP3(bp)) ;
		bi->SetBP2(::ToP3(bp)) ;
		}

「0xC0000005」エラーでWindows 11インストール不可
[Solved] – Fix Error Code 0xc0000005 in Windows
【Win10/11】エラーコード0xc0000005を修正する方法
【Windows】エラーコード「0xc0000005」が出る原因と直し方
Office (Outlook, Excel, Word, PowerPoint)などのソフト を起動すると「0xc0000005」エラーが出る場合の対処法

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