ホーム » VC (ページ 7)

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

2024年5月
 1234
567891011
12131415161718
19202122232425
262728293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 81,270 アクセス



Win10 に入っている MFC*.dll

MFC の DLL に関して調べていて,
Win10 では幾つかの MFC DLL がインストールされているという記述を見つけたので調べてみました.


VirtualBox で仮想環境を作成して,Win10 Pro 1903 をインストール.
Win10 Pro 1903
インストールされているものは仮想マシン用のツール.
Win10 Pro プログラムと機能
このような環境で C ドライブを mfc*.dll で検索すると,見つかるのは前から存在するもの.
mfc40.dll mfc40u.dll mfc42.dll mfc42u.dll
Win10 Pro  mfc*.dll で検索した結果
Win10 のバージョンによるのかどうかわかりませんが,
OS のみのインストール状態では mfc140u.dll は入っていないようです.


私の方で MFC dll をダウンロードするページへのリンクをまとめています.
http://i_tools.mish.work/2017/05/
https://jml.mish.work/index.php/cpp/ref-vcredist-xxx-exe.html


2019/06/15
msvc???.dll などは入っていたのでその画面コピーです.
msvcr???.dll
msvcp???.dll
msvc????.dll
msvc????.dll バージョンでソート 1
msvc????.dll バージョンでソート 2


2022/10/06
Win11 に入っている MFC*.DLL

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

VS 2019 インストール

Win10 環境に VS 2005 ~ 2019 までをインストール.
VS 2019
XP でも動作する exe を作成する には,「プロジェクトのプロパティ」-「プラットフォーム ツールセット」を「Visual Studio 2017 – Windows XP (v141_xp)」に.
VC 2019 プラットフォーム ツールセット

------ ビルド開始: プロジェクト: i3DV, 構成: Release Win32 ------
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets(39,5): warning MSB8051: Windows XP をターゲットとするサポートは非推奨であり、Visual Studio の将来のリリースで提供されなくなります。詳細については、https://go.microsoft.com/fwlink/?linkid=2023588 をご覧ください。
StdAfx.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
ChildFrm.cpp
\\devs\documents\develop\_.src\__iwao\xml_ms_.hxx(17): warning C4192: 'ISequentialStream' を自動的に除外し、タイプ ライブラリ 'msxml6.dll' をインポートします
\\devs\documents\develop\_.src\__iwao\xml_ms_.hxx(17): warning C4192: '_FILETIME' を自動的に除外し、タイプ ライブラリ 'msxml6.dll' をインポートします
i3DV.cpp
i3DVDoc.cpp
i3DVView.cpp
MainFrm.cpp
...
コードを生成中...
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\sal.h(2866): warning RC4005: '__useHeader' : redefinition
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\sal.h(2876): warning RC4005: '__on_failure' : redefinition
i3DV142.vcxproj -> c:\Temp\i_Tools\i3DV\Release.142\Win32\i3DV.exe
プロジェクト "i3DV142.vcxproj" のビルドが終了しました。
========== ビルド: 1 正常終了、0 失敗、0 更新不要、0 スキップ ==========

Visual Studio 2019 (v142)」に戻してビルドすると,

------ ビルド開始: プロジェクト: i3DV, 構成: Release Win32 ------
StdAfx.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.20.27508\atlmfc\include\afx.h(62): fatal error C1083: include ファイルを開けません。'new.h':No such file or directory
プロジェクト "i3DV142.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========

Windows SDK バージョン」が「7.0」になっているので「10.0 (最新のインストールされているバージョン)」に.

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

VS 2013 インストールに失敗

Win10 に,以前ダウンロードした VS 2013 iso でインストールしようとすると途中で失敗する.
VS 2013 インストール エラー
ja_visual_studio_professional_2013_with_update_5_x86_dvd_6815755.iso
丁度一年前にダウンロードしたもので,ファイルサイズは 3.71 GB .
VS 2013 with update 5 iso の情報
検索すると,
VS 2013 Professional insatlation problem with microsoft visual studio 2013 vsgraphics helper dependencies incorrect function
どうも iso が壊れている?みたいで,もう一度落とし直した.
今回落とした VS 2013 with update 5 iso の情報
ファイル名は同じだがサイズが異なる.
もう一度インストールしてみるとうまくいった.

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

3DS 保存でアプリケーションエラー

次の様な 3DS 形式で保存するコード.
データ部分が空の時,アプリケーションエラー.
3DS 保存でアプリケーションエラー

bool	save_3DS	(FILE* ofp,const tDS_Chunk& chnk)
{
	if (ofp == NULL)		{	return	false ;		}
	{
		u_16	id  = chnk.GetID() ;
		u_32	len = chnk.GetLen() ;
		v_u__8	data= chnk.GetData() ;
		::fwrite(&id,		1,		sizeof(u_16),	ofp) ;
		::fwrite(&len,		1,		sizeof(u_32),	ofp) ;
		::fwrite(&data[0],	data.size(),	sizeof(u__8),	ofp) ;
		}
	for (size_t index=0 ; index<size_t(chnk.GetChildCount()) ; index++) {
		tDS_Chunk	child = chnk.GetChild(long(index)) ;
		bool	result = ::save_3DS(ofp,child) ;
		if (!result)		{	return	false ;		}
		}
	return	true ;
	}

::fwrite(&data[0], data.size(),sizeof(u__8), ofp) ; がうまくない.
次の様な感じでコードを修正.

if (data.size() > 0) {	::fwrite(&data[0],	data.size(),	sizeof(u__8),	ofp) ;	}

VC 6 や VC 14 では,たまたまだと思うがエラーにならなかった.


VC 14 デバッグ版では,アサートされることを確認.
サイズ 0 の vector の fwrite VC 14 デバッグ版でアサート

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

C1189 : WINDOWS.H already …

幾つかの,MFC を使用していないプロジェクトをビルドしていると,

--------------------構成: GAtoSTL - Win32 Release--------------------
コンパイル中...
GAtoSTL.cpp
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
cl.exe の実行エラー

GAtoSTL.obj - エラー 1、警告 0

MFC アプリでは windows.h をインクルードしてはいけないというエラー.
最近(2019/03)変更したコードで,意図せず Afx.h などを利用するようになってしまった所があると思われる.
今回の場合,デバッグ版や Linux 環境,VC 14 などでは通っている.


次の様な内容を include している部分に挿入して確認すると,
 #pragma message (“message 1”)
Zip.hxx がうまくない.

#ifndef		I_SUPPORT_ZIP			//	ここは個人的なコードです
	#ifdef	_DEBUG
		#include	"i_Zip.hxx"	//	STL と Windows.h
	#else
		#include	"a_Zip.hxx"	//	AfxDisp などを使用
	#endif
#endif

a_Zip.hxx は zip を扱う古い形式(MFC を使用している)のもの.
i_Zip.hxx は MFC を使用しないように変更したもの.
a_Zip.hxx を使用しないように変更.


2019/08/26 追加
このエラーが表示される原因は,
MFC 関連の afx*.h がインクルードされる前に Windows.h が読み込まれているため.
MFC を使用しているプロジェクトで StdAfx.h を使用してない場合は,
ソース内のヘッダのインクルードで最初に #include <afxwin.h> などとすれば良い.
#include <afxwin.h>
2020/02/14
それから,作成したヘッダファイル内では Afx*.h のインクルードはしない方が良さそう.
https://dev.mish.work/wordpress/2020/02/08/lnk2005-operator-delete/


次のエラーの場合はこちら
error C1189: #error: Please use the /MD switch for _AFXDLL builds
fatal error C1189: #error: Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]


2020/10
コンソール AP で Windows.h を使用する時の hxx を用意した.
コンソール AP での define
_AFXDLL で判断しているため 「MFC のスタティックライブラリを使用」には対応できない


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

VC フォールバック 設定

以前から設定している情報のまとめ


VC 10 以降 フォールバックの設定
「ツール」-「オプション」-「テキスト エディター」-「C/C++」-「詳細」.
VC 「フォールバック」の設定
*.ipch,*.sdf,*.VC.db などを指定フォルダ以下に作成するように変更.


VC 7 以降 exe などをプロジェクトのソースなどとは別の所に生成するために.
VC 出力ディレクトリ
c:\Temp\$(ProjectName)\$(ConfigurationName).070
c:\Temp\$(ProjectName)\$(ConfigurationName).080\$(PlatformName)\
c:\Temp\$(ProjectName)\$(ConfigurationName).090\$(PlatformName)\
c:\Temp\$(ProjectName)\$(Configuration).100\$(Platform)\
c:\Temp\$(ProjectName)\$(Configuration).140\$(Platform)\
c:\Temp\Test_3D\$(ProjectName)\$(Configuration).100\


https://mish.work/Iwao/Doc/other/vs/
https://mish.work/joomla/index.php/cpp/vs-install.html

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

コンパイルエラー C2664

次の様になっている _UNICODE のプロジェクトでエラー.
//#include “messbar.hxx
#include “i_dib_bg.hxx
#include “itls_tmp.hxx

--------------------構成: Tc_i_DIB - Win32 Release--------------------
コンパイル中...
Tc_i_DIB.cpp
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(71) : error C2664: 'wcscpy' : 1 番目の引数を 'char *' から 'unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(72) : error C2664: 'wcslen' : 1 番目の引数を 'const char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(88) : error C2664: 'wcsncpy' : 1 番目の引数を 'char *' から 'unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(105) : error C2664: 'wcscat' : 1 番目の引数を 'char *' から 'unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(106) : error C2664: 'wcslen' : 1 番目の引数を 'const char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(106) : error C2664: 'wcslen' : 1 番目の引数を 'char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(127) : error C2664: 'wcsncat' : 1 番目の引数を 'char *' から 'unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(128) : error C2664: 'wcslen' : 1 番目の引数を 'const char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(128) : error C2664: 'wcslen' : 1 番目の引数を 'char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(171) : error C2664: '_wcslwr' : 1 番目の引数を 'char *' から 'unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(186) : error C2664: '_wcsupr' : 1 番目の引数を 'char *' から 'unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(211) : error C2664: '_wgetenv' : 1 番目の引数を 'const char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(235) : error C2664: '_wcreat' : 1 番目の引数を 'const char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\_s_func.hxx(259) : error C2664: '_wfopen' : 1 番目の引数を 'const char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\ttox.hxx(32) : error C2664: 'wcstoul' : 1 番目の引数を 'const char *' から 'const unsigned short *' に変換できません。 (新しい機能 ; ヘルプを参照)
        指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
\\DevS\Documents\Develop\_.SRC\__CPR_\ttox.hxx(32) : fatal error C1903: 直前のエラーを修復できません; コンパイルを中止します。
cl.exe の実行エラー

Tc_i_DIB.exe - エラー 16、警告 0

_MBCS にすると OK .
また,コメントにした “messbar.hxx” のインクルードを外すと OK .
::DIB_resize_bg の実行結果
エラーは UNICODE 版の関数を使用しているのに char を与えているというもの.
wcscpy を呼び出すときの引数を char* ではなく wchar_t* にすれば良い.
または,_MBCS ,_UNICODE 共に動作する様に _tcscpy の様な関数と TCHAR を使用する.


2019/01/31
今回エラーになったのは次の様なコード.

bool	TcsCpy	(LPTSTR dst,size_t sizeD,LPCTSTR src)
{
	if (sizeD == 0)				{	return	false ;	}
	bool	rs = true ;
	#if(_MSC_VER >= 1400)
	{
		errno_t	err =	_tcscpy_s	(dst,sizeD,	src) ;
		if (err != 0)			{	rs = false ;	}
		}
	#else
	{
				_tcscpy 	(dst,		src) ;
		if (sizeD < _tcslen(src))	{	rs = false ;	}
		}
	#endif
	return	rs ;
	}

原因は _UNICODE が定義 されていて UNICODE が定義されていない ことによるもの.
ビルド環境?によってこれらの #define が矛盾してしまうことがある.
Windows.h をインクルードする前に両方が定義されている必要がある.
今回は自前の def_bmp.hxx の先頭に,i_define.hxx をインクルードすることで対応.
i_define.hxx 内では,次の様にしている.

//	(VS8)\VC\AtlMFC\Include\AfxV_W32.h 
#ifdef			_MSC_VER
	#ifdef		_UNICODE
		#ifndef	 UNICODE
		#define	 UNICODE		// UNICODE is used by Windows headers
		#endif
	#endif
	#ifdef		 UNICODE
		#ifndef	_UNICODE
		#define	_UNICODE		// _UNICODE is used by C-runtime/MFC headers
		#endif
	#endif
#endif

2020/09
i_def_aw.hxx を用意.
コンソール AP での define


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

xml の読込み – 2

昨日の xml 読込み で,データが大きい場合に比例ではなく極端に遅くなる?
それで,次の様なコードで計測してみた.

bool Test (c_tstring& str)
{
    for (size_t index=0 ; index<str.size() ; index++) {
        ElapseTime et ;
        tstring s_str = ::Parse_xml_quot(str,_T('|'), &index) ;
        std::cerr << ::To_tstring_Ki(long(s_str.size())) << _T("\t") << et.GetElapse() << std::endl ;
        }
    return true ;
    }

bool Test (void)
{
    tstring outPath = ::Get_i_Tools_tmp_date() ;
    tstring now_hms = ::Now_Format(_T("%H%M%S")) ;
    tstring out_txt = ::Path_AddLastSP(outPath) + now_hms + _T(".txt") ;
    tstring outrtxt = ::Path_AddLastSP(outPath) + now_hms + _T("_.txt") ;
    tstring str ;
    {
        v_tstring strAry ;
        {
            tstring str_1000 ;
            {
                tstring str_10 = _T("0123456789") ;
                for (long indexS=0 ; indexS<100 ; indexS++) {
                    str_1000 += str_10 ;
                    }
                }
            for (long index=0 ; index<2000 ; index++) {
                strAry.push_back(str_1000) ;
                }
            }
        str = ::String_Join_Line(strAry) ;
        }
    str[0] = _T('|') ;
    str += _T('|') ;
    size_t len = str.length() ;
    while (len > 100) {
        len = len/2 ;
        str[len-0] = _T('|') ;
        str[len-1] = _T('|') ;
        }
    {
        tstring tmp = str ;
        v_tstring tmpAry = ::String_Split(tmp.c_str(),false) ;
        tmpAry = ::SkipEmpty(tmpAry) ;
        str = ::String_Join_Line(tmpAry) ;
        }
    {
        ::SaveUTF8(out_txt.c_str(),str) ;
        ::Test(str) ;
        }
    {
        tstring rev = str ;
        {
            std::reverse(rev.begin(),rev.end()) ;
            v_tstring revAry = ::String_Split(rev.c_str(),false) ;
            revAry = ::SkipEmpty(revAry) ;
            rev = ::String_Join_Line(revAry) ;
            }
        ::SaveUTF8(outrtxt.c_str(),rev) ;
        ::Test(rev) ;
        }
    return true ;
    }

DS116 では,比例と思われる.

login as: Iwao
Iwao@DS116's password:
Iwao@DS116:~$ source ./set_ds_inc.sh
Iwao@DS116:~$ cd gcc_test/Test/T_P_xm_q/
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ g++ T_P_xm_q.cpp
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ ll
total 204
drwxrwxrwx+  2 Iwao users   4096 Jan  8 14:10 .
drwxrwxrwx+ 10 Iwao users   4096 Jan  8 14:09 ..
-rwxrwxrwx   1 Iwao users 183528 Jan  8 14:10 a.out
-rwxrwxrwx+  1 Iwao users   3009 Jan  8 13:59 T_P_xm_q.cpp
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ ./a.out
     61         0.000384092
     61         6.10352e-05
    122         5.31673e-05
    245         5.19753e-05
    489         6.29425e-05
    979         8.70228e-05
  1.91 K        0.000140905
  3.82 K        0.000212908
  7.64 K        0.000381947
 15.29 K        0.000729799
 30.58 K        0.00145721
 61.16 K        0.0028069
122.32 K        0.00562811
244.63 K        0.011224
489.26 K        0.0223849
978.52 K        0.0462639
      0         5.38826e-05
      0         3.91006e-05
978.52 K        0.045109
489.26 K        0.022413
244.63 K        0.0112309
122.32 K        0.00556397
 61.16 K        0.00286198
 30.58 K        0.00143504
 15.29 K        0.000734806
  7.64 K        0.000383139
  3.82 K        0.000211
  1.91 K        0.000123024
    979         8.51154e-05
    489         6.19888e-05
    245         5.00679e-05
    122         4.3869e-05
     61         4.00543e-05
     61         3.91006e-05
      0         3.31402e-05
      0         3.31402e-05
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$

VC 6 は比例でなく,もっとかかっている.VC 14 では問題ない.VC 8 以降?は大丈夫だと思う.

C:\Users\Iwao>C:\Users\Iwao\AppData\Local\Temp\MICS.tmp\Temp\Test.exe\T_P_xm_q.exe
     61         0
     61         0
    122         0
    245         0
    489         0
    979         0
  1.91 K        0
  3.82 K        0
  7.64 K        0
 15.29 K        0
 30.58 K        0.016
 61.16 K        0.016
122.32 K        0.109
244.63 K        0.531
489.26 K        2.433
978.52 K        14.68
      0         0
      0         0
978.52 K        14.664
489.26 K        1.342
244.63 K        0.374
122.32 K        0.125
 61.16 K        0.016
 30.58 K        0.015
 15.29 K        0
  7.64 K        0
  3.82 K        0
  1.91 K        0
    979         0
    489         0
    245         0
    122         0
     61         0
     61         0
      0         0
      0         0

C:\Users\Iwao>

parse_xml_quot をグラフ化
修正のコードは,

tstring Parse_xml_quot (c_tstring& str,const TCHAR qm,size_t* index)
{
    tstring q_str ;
    if (*index < str.length()) {
        TCHAR c = str[*index] ;
        if (c == qm) {
            /*
            q_str += c ;
            for (size_t indexQ=*index+1 ; indexQ<str.size() ; indexQ++) {
                TCHAR cq = str[indexQ] ;
                q_str += cq ;
                if (cq == qm) {
                    *index = indexQ ;
                    break ;
                    }
                }
            */
            size_t pos = ::String__Find(str,qm,*index+1) ;
            if (pos == tstring::npos) {
                q_str = str.substr(*index) ;
                *index = str.length() ;
                }
            else {
                size_t q_len = pos+1 - *index ;
                q_str = str.substr(*index,q_len) ;
                *index = pos ;
                }
            }
        }
    return q_str ;
    }

parsexml.hxx


2019/06/06
2019/01 のコードは属性の値のネスト(attr='”a” “b”‘)に対応できてないバグあり.


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

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

xml の読込み

幾つかの xml データを読んでみると,データにより msxml.dll を使用したときに比べて明らかに遅い.

bool Test (LPCTSTR pathName)
{
    tstring outPath = ::Get_i_Tools_tmp_date() ;
    tstring now_hms = ::Now_Format(_T("_%M%S")) ;
    tstring out_xml = ::Path_AddLastSP(outPath) + ::Path_GetName(pathName) + now_hms + _T(".o.xml") ;
    tstring new_xml = ::Path_AddLastSP(outPath) + ::Path_GetName(pathName) + now_hms + _T(".n.xml") ;
    {
        ElapseTime eto ;
        Xml_E xml = ::Xml_Import(pathName) ;
        std::cerr << eto.GetElapse() << std::endl ;
        Xml_Out::Export(xml,out_xml.c_str()) ;
        }
    {
        ElapseTime etn ;
        Xml_E xml = ::Load_xml_2018_12(pathName) ;
        std::cerr << etn.GetElapse() << std::endl ;
        Xml_Out::Export(xml,new_xml.c_str()) ;
        }
    return true ;
    }

データは次の様な x3d で,5 倍くらいかかる.

Parse_xml で時間がかかる x3d
Parse_xml で時間がかかる x3d

x3d の場合は,属性の値が長い.
そのため次のコード部分( q_str+=cq )がうまくない.

tstring Parse_xml_quot (c_tstring& str,const TCHAR qm,size_t* index)
{
    tstring q_str ;
    if (*index < str.length()) {
        TCHAR c = str[*index] ;
        if (c == qm) {
            q_str += c ;
            for (size_t indexQ=*index+1 ; indexQ<str.size() ; indexQ++) {
                TCHAR cq = str[indexQ] ;
                q_str += cq ;
                if (cq == qm) {
                    *index = indexQ ;
                    break ;
                    }
                }
            }
        }
    return q_str ;
    }

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

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

include ファイルの大文字

Windows 上で動作しているコンソール AP の Synology NAS 上での動作テスト.
NAS 上でコンパイルすると include ファイルがないエラー.
今まで include する時,大文字と小文字を正しく指定できていた.
が,今回タイプミスで小文字となってしまっていたためのエラー.


g++ 時に大文字,小文字を無視する方法がないか調べたがわからず.
いろいろ考えたが,Linux 環境などでも互換性が取れるコードは小文字のファイル名とすれば都合が良さそう.
MFC や Windows.h を使用している時は,今まで通り大文字が混在するファイル名とする.

インクルードしているファイル

関連するファイルを全て編集するのは時間がかかるし間違いも増えそう.
そこで,新規のファイルと変更するファイルなどから徐々に修正することにする.
新規や変更時,include する所で lowname.hxx などとする.
LowName.hxx となっているファイルは,gcc でのみインクルードするディレクトリにコピー.
元のファイルは lowname.hxx にリネーム.
gcc にコピーした LowName.hxx は #include “lowname.hxx” の様に間接的にインクルードする様に変更する.
これでうまく機能することは確認した.
が,robocopy や Dropbox を使用している関係で lowname.hxx にならないことがある.


2019/04/16 追記
robocopy で lowname.hxx にならないことに関しては,一度コピー先を削除(実際は移動)して対応.

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

カメラ座標からワールドに

{
    Prj ctow ;
    {   //  Prj の逆行列を求める
        Matrix pm ;
        Prj    prj(GetEyeChg().Get()) ;
        prj.Get(&pm) ;
        pm.Inv() ;	//  逆行列
        ctow.Set(pm) ;
        }
    for (size_t index=0 ; index<pnts.size() ; index++) {
        Vd3 pnt = pnts[index] ;
        for (size_t index3=0 ; index3<pntsXzY.size() ; index3++) {
            Vd3 pt3 = pntsXzY[index3] ;
            pt3.y = 0 ;
            if (::V3_is_near(pnt,pt3)) {
                Vd3 pntc = pntsXzY[index3] ;
                Vd3 pntw = ::ToVd3(ctow.P3to3(::ToP3(pntc))) ;  //  逆行列を掛けている
                pnts[index] = pntw ;
                break ;
                }
            }
        }
    }


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

template の複数の型の順番

先日作成した template .
  template <class V3, class VT> V3 ToV3 (const VT& vt,const long type)
型の順番で,戻り値の型 V3 と,引数の型 VT .
どちらを先に指定した方が良いか悩んだが,呼び出しで省略する場合を考慮するとこれで良さそう.
  Vd4 v4(1,2,3,1) ;
  Vd3 v3(1,2,3) ;
  Vd2 v2(1,2) ;
  Vd3 v43 = ToV3<Vd3/*,Vd4*/>(v4,to_x0y) ;
  Vd3 v33 = ToV3<Vd3/*,Vd3*/>(v3,to_x0y) ;
  Vd3 v23 = ToV3<Vd3/*,Vd2*/>(v2,to_x0y) ;

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

::ToV3<Vd3,Vd2>(v2,to_x0y) で C2784

次の様な template の利用で,C2784 エラー.

    Vd2 v2(1,2) ;
    Vd3 v3 = ::ToV3<Vd3,Vd2>(v2,to_x0y) ;

\\DevS\...\tovxx.hxx(123) : error C2784: 'struct Vector3<T> __cdecl ToX0Y(const struct Vector4<T> &)' : 'const struct Vector4<T> & 用のテンプレート引数を 'const struct Vector2<double>' から減少できませんでした。 C:\... \VF3DView.cpp(236) : コンパイルされたクラスのテンプレートのインスタンス化 'struct Vector3<double> __cdecl ToV3(const struct Vector2<double> &,const long)' の参照を確認してください
template <class V3, class VT> V3 ToV3 (const VT& vt,const long type) { V3 v3 ; { switch (type) { case to_xyz : v3 = ::ToXYZ(vt) ; break ; case to_xzy : v3 = ::ToXZY(vt) ; break ; case to_x0y : v3 = ::ToX0Y(vt) ; break ; default : v3 = ::ToXYZ(vt) ; break ; } } return v3 ; }
Vector4 のものは昨日定義していたが,Vector2 のものを追加.ついでに Vector3 も. template <class T> Vector3<T> ToXYZ (const Vector2<T>& p) { return Vector3<T> (p.x,p.y, 0 ) ; } template <class T> Vector3<T> ToXYZ (const Vector3<T>& p) { return Vector3<T> (p.x,p.y,p.z) ; } template <class T> Vector3<T> ToXZY (const Vector2<T>& p) { return Vector3<T> (p.x, 0 ,p.y) ; } template <class T> Vector3<T> ToXZY (const Vector3<T>& p) { return Vector3<T> (p.x,p.z,p.y) ; } template <class T> Vector3<T> ToX0Y (const Vector2<T>& p) { return Vector3<T> (p.x, 0 ,p.y) ; } template <class T> Vector3<T> ToX0Y (const Vector3<T>& p) { return Vector3<T> (p.x, 0 ,p.y) ; }

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

template で複数の型を指定

template で複数の型を指定する場合は,カンマで区切って指定すれば良い.

    template <class V2, class V3> V2 ToV2 (const V3& v3,const long type)
    {
        V2 v2 ;
        switch (type) {
            case to_xy : v2 = ::ToXY(v3) ; break ;
            case to_yz : v2 = ::ToYZ(v3) ; break ;
            case to_zx : v2 = ::ToZX(v3) ; break ;
            case to_xz : v2 = ::ToXZ(v3) ; break ;
            default :    v2 = ::ToXY(v3) ; break ;
            }
        return v2 ;
        }

呼び出しは,次の様な感じ.

    Vd3 v3 = Vd3(1,2,3) ;
    Vd2 v2 = ::ToV2<Vd2,Vd3>(v3,to_xy) ;

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

ファイルの検索

あるフォルダ内のファイルを列挙するコード 

MFC
v_tstring	EnumFiles_MFC	(c_tstring& path,const bool skipDot=true)
{
	v_tstring	foundFiles ;
	{
		iFileFind	ff ;
		BOOL		isWorking = ff.FindFile((::Path_AddLastSP(path)+_T("*.*")).c_str()) ;
		while	(isWorking)	{
			 	isWorking = ff.FindNextFile() ;
			if (skipDot && ff.IsDots()) {	continue ;	}
			tstring	fileName = ff.GetFileName() ;
			if (ff.IsDirectory()) {
				fileName = ::Path_AddLastSP(fileName) ;
				}
			foundFiles.push_back(::Path_AddLastSP(path)+fileName) ;
			}
		}
	return	foundFiles ;
	}

MSC
v_tstring	EnumFiles_MSC	(c_tstring& path,const bool skipDot=true)
{
	v_tstring	foundFiles ;
	{
		tstring	fffPath = ::Path_AddLastSP(path)+_T("*.*") ;
		WIN32_FIND_DATA	fd ;
		memset(&fd,0,sizeof(WIN32_FIND_DATA)) ;
		HANDLE	hFind = ::FindFirstFile(fffPath.c_str(),&fd) ;
		if (hFind != INVALID_HANDLE_VALUE) {
			while	(TRUE)	{
				tstring	fileName = fd.cFileName ;
				if (skipDot) {
					if (fileName == _T("."))   {	fileName = _T("") ;	}
					if (fileName == _T(".."))  {	fileName = _T("") ;	}
					}
				if (!fileName.empty()) {
					if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
						fileName = ::Path_AddLastSP(fileName) ;
						}
					foundFiles.push_back(::Path_AddLastSP(path)+fileName) ;
					}
				if (!::FindNextFile(hFind,&fd)) {
					break ;
					}
				}
			::FindClose(hFind) ;
			}
		}
	return	foundFiles ;
	}

GNUC
v_tstring	EnumFiles_GNUC	(c_tstring& path_,const bool skipDot=true)
{
	tstring 	path = path_ ;
	v_tstring	foundFiles ;
	{
		DIR*	dp = ::opendir(path.c_str()) ;
		struct	dirent*	dent = NULL ;
		do	{
			dent = readdir(dp) ;
			if (dent != NULL)	{
				tstring	fileName = dent->d_name ;
				if (skipDot) {
					if (fileName == _T("."))   {	continue ;	}
					if (fileName == _T(".."))  {	continue ;	}
					}
				if (dent->d_type & DT_DIR) {
					fileName = ::Path_AddLastSP(fileName) ;
					}
				foundFiles.push_back(::Path_AddLastSP(path)+fileName) ;
				}
			}	while (dent != NULL) ;
		::closedir(dp) ;
		}
	return	foundFiles ;
	}

MFC 版で,iFileFind としているのは,VC 6 MFC MBCS 版でのバグのため.

class	iFileFind	:	public	CFileFind	{
	public:
		virtual	CString GetFilePath() const	{
			ASSERT(m_hContext != NULL);
			ASSERT_VALID(this);
			CString strResult = m_strRoot;
			#ifdef	____VC_6_______MBCS_BUG___
			{
				if (strResult[strResult.GetLength()-1] != '\\' &&
					strResult[strResult.GetLength()-1] != '/')	{
					strResult += m_chDirSeparator;
					}
				}
			#else
			{
				LPCTSTR pszResult;
				LPCTSTR pchLast;
				pszResult = strResult;
				pchLast = _tcsdec( pszResult, pszResult+strResult.GetLength() );
				VERIFY(pchLast!=NULL);
				if ((*pchLast != _T('\\')) && (*pchLast != _T('/')))	{
					strResult += m_chDirSeparator;
					}
				}
			#endif
			strResult += GetFileName();
			return strResult;
			}
		} ;

MFC 7 以降であれば,CFileFind として利用可能.


i_FileF.hxx
enumfile.hxx

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

vector<Xxxx<T>> の利用でのエラー

template <class T> Extent2<T> E2_GetExtent (const std::vector<VLine2<T>>& lins)     //  エラー
template <class T> Extent2<T> E2_GetExtent (const std::vector< VLine2<T> >& lins)   //  OK

vector<VLine2<T>> の様にスペースがないとエラーになる.
vector<  VLine2<T>  > の様に空ければ OK .

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

#define での括弧 …

STL バイナリのサイズをチェックする所でうまく判断できず,気が付くまで少し時間がかかったのでメモ.
   u_64 dataSize = STL_B_H_COUNT_SIZE + faceCount * STL_B_FACE_1_SIZE ;
   if (dataSize == fileSize) { return true ; }
STL_B_FACE_1_SIZE が 4*3*4+2 となっていて,84 + faceCount * 48 + 2 になってしまっていた.
括弧で括って 84 + faceCount * 50 で OK .
#define     STL_B_FACE_1_SIZE       (4*3*4+2)

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

C1076 ヒープの領域を…

——————–構成: MkCmf – Win32 Debug——————–
コンパイル中…
ComPrj03.cpp
c:\program files\microsoft visual studio\vc98\include\comip.h(46) : fatal error C1076: コンパイラの制限 : ヒープの領域を使い果たしました; 上限を設定するために /Zm オプションを使用してください。
cl.exe の実行エラー
ComPrj03.obj – エラー 1、警告 0


VC 7 では,
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\ostream(632) : fatal error C1076: コンパイラの制限 : 内部ヒープの上限に達しました。上限を変更するには /Zm オプションを使用してください。


MSDN /Zm
コンパイルのオプションに /Zm150 を追加.
VC 6 /Zm の設定

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

template でのキャスト

次の様なベクトルの template .

	template <typename T>
	struct	Vector3 {
	//	...
		void	Normalize	(void)	{
			if (Length() > 0) {
				double	s = 1.0f / Length() ;
				x *= s;
				y *= s;
				z *= s;
				}
			}
	//	...
		T	x ;
		T	y ;
		T	z ;
		} ;	

double の時は問題ないが,float だとワーニング.
T(value) として対応.

				double	s = 1.0f / Length() ;
				x = T(x*s) ;
				y = T(y*s) ;
				z = T(z*s) ;	
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

pgons.Material::operator=(pgons1)

	d3D_PgonsA	pgsa = c3d.GetPgonsA() ;
	{
		d3D_PgonsA	pa_tri ;
		for (long index=0 ; index<pgsa.GetCount() ; index++) {
			d3D_Pgons1	pgns1 = pgsa[index] ;
			d3D_Pgons1	pgons = pgns1 ;
			{
					pgons = ::Pgons_ToTriangle(pgns1) ;
				//	pgons.SetColor  (pgns1.GetColor  ()) ;
				//	pgons.SetTexture(pgns1.GetTexture()) ;
				//	pgons.SetName   (pgns1.GetName   ()) ;
					pgons.Material::operator=(pgns1) ;
				}
			pa_tri.Add(pgons) ;
			}
		pgsa = pa_tri ;
		}
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.