ホーム » gcc (ページ 4)

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

2024年3月
 12
3456789
10111213141516
17181920212223
24252627282930
31  

カテゴリー

アーカイブ

ブログ統計情報

  • 77,359 アクセス



ファイルの検索

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

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.

#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.

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.

Synology NAS で文字色

別の事を調べていて,次の様な内容を見つけたので Synology NAS でやってみた.
C言語でターミナルで表示される文字をカラー表示させる
コードはそのまま拝借させてもらった.
ANSI escape code

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

球が作成できない

背景画像のアップロードで,球を生成してそれに貼り付ける.
コード自体はそれほど難しくないので,1 日位でできると思ってた.
Windows のコンソール AP で,次の様なコードを書いてテスト.
MakeBG.cpp
make_bg.hxx


#include "MessBar.hxx"
#include "i_Trace.hxx"
#include "gonsprm2.hxx"
#include "Htm_thrj.hxx"

//*******************************************************************************
// make bg files imo and html
// Create : 2018/04/19
//*******************************************************************************
inline bool MakeBG (c_tstring& dibPath)
{
    tstring ext = ::Path_GetExtLow(dibPath) ;
    if      (ext == _T("bmp")) { ;              }
    else if (ext == _T("jpg")) { ;              }
    else if (ext == _T("png")) { ;              }
    else                       { return false ; }
    {
        tstring imoPath = ::Path_ChangeExt(dibPath,_T(".imo")) ;
        tstring htmName = ::Path_ChangeExt(dibPath,_T(".html")) ;
        tstring dmpName = ::Path_ChangeExt(dibPath,_T(".ipl")) ;
        {
            long div = 90/5 ;
            v_Vd3A pntsAry = ::BuildSphere(div) ;
            {
                std::tout << pntsAry.size() << std::endl ;
                if (pntsAry.size() > 0) {
                    Vd3A pnts = pntsAry[0] ;
                    std::tout << pnts.size() << std::endl ;
                    }
                tstring str = ::v_V3_To_tstring(pntsAry,_T(",")) ;
                {
                    std::tout << str << std::endl ;
                    }
                ::SaveText(dmpName.c_str(),str) ;
                }
            v_Vd2A  txuvAry = ::SetTextureUV(pntsAry) ;
                    pntsAry = ::V3_Scale (pntsAry,Vd3(20.)) ;
            Gons1   gons1 = ::Gons_BuildFace(pntsAry,txuvAry,dibPath.c_str()) ;
            GonsA   ga ;
                    ga.push_back(gons1) ;
            Ed3     es = ::GonsA_GetExtent(ga) ;
            {
                std::tout << imoPath << _T("\t") ;
                std::tout << ::V3_To_tstring(es.Volume()) << std::endl ;
                }
            if (es.Volume() != Vd3(0)) {
                es = Ed3(es.L*0.01,es.G*0.01) ;
                ::GonsA_ToOBJ(ga,imoPath.c_str()) ;
                ::HT_Make_three_js_html(imoPath.c_str(),es) ;
                }
            }
        }
    return true ;
    }

//*******************************************************************************
// Make BG
// Create : 2018/04/19
//*******************************************************************************
int _tmain (int argc,TCHAR* argv[])
{
    _tsetlocale(LC_ALL,_T("")) ;
    {
        double s = sin(rad(30)) ;
        double c = cos(rad(30)) ;
        std::tout << ::To_tstring(rad(30)) << _T("\t") << ::To_tstring(s) << _T("\t") << ::To_tstring(c) << std::endl ;
        }
    if (argc > 1) {
        v_tstring argAry ;
        for (int index=1 ; index<argc ; index++) {
            tstring av = argv[index] ;
            ::MakeBG(av) ;
            }
        }
    else {
        tstring buf ;
        buf.resize(1000) ;
        {
            while (std::terr << _T("dib ? =") , std::tin.getline(&buf[0],buf.size()))
            {
                tstring str = buf.c_str() ;
                if      (str == _T("q"))   { break ; }
                else if (str == _T("Q"))   { break ; }
                str = ::QuotM_Del_All(str) ;
                if (str.empty())           { continue ; }
                if (::File_IsNothing(str)) { continue ; }
                tstring dib_file = str ;
                ::MakeBG(dib_file) ;
                }
            }
        }
    return 0 ;
    }

#include "MessBar.cxx"

今度は,DS116 でビルドして実行すると,

Iwao@DS116:/var/.../Test/up_bg/data$ ./a.out
0.523599        98314745853377985068733249901357667205561433229409406145971019710277043155206326909160297391588106447153156445277590513896008090831662627743743127151181611161993303763348552511914898438567008016612049817143085994563143448055356356529593034366351316506187159487365573007925410016860727208738652774465536.000000  98321247861193438769252981549279948821735544950351014769381393881588573259178110828643912278175146924986161470094082713103803921735703931192359519739047155548857037547932930737608178537416409042994283830606984599100883034181136178714087912736395732787698542049681305006129736011480288874859116047106048.000000
dib ? =

本当は,

C:\Users\Iwao\...\i_Tools.tmp>\\DevXP\C_Drive\Temp\DS11x\MakeBG\Release.060\MakeBG.exe
0.523599        0.500000        0.866025
dib ? =

cmath が使えない様で,検索すると「-lm でコンパイルが通る」と言うのは見つかる.
が,コンパイルの問題ではなく,実行でうまくない.


当然ではあるが,DS115j でも同様.
試しに,opkg update と opkg install gcc .
root@DS116:/var/…/Iwao# opkg update
Downloading http://pkg.entware.net/binaries/armv7/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/packages
root@DS116:/var/…/Iwao# opkg install gcc
Upgrading gcc on root from 6.3.0-1 to 6.3.0-1a…
Downloading http://pkg.entware.net/binaries/armv7/gcc_6.3.0-1a_armv7soft.ipk
Configuring gcc.
root@DS116:/var/…/Iwao#
もう一度,ビルドして実行すると,
Iwao@DS116:/var/…/Test/up_bg/data$ g++ MakeBG.cpp
Iwao@DS116:/var/…/Test/up_bg/data$ ./a.out
0.523599 0.500000 0.866025
dib ? =
予想以上に時間がかかってしまったが,何とか…
daikoku_edit.html


2019/02/13 リンクなどを修正

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

データの送信 socket

3D データをアップするのに,複数のファイルを指定するのが面倒
調べてみると socket でいけそう?


利用するのは Win AP なので,MFC で良いかと思い調べると
CAsyncSocket や CSocket は適切ではないとのこと.
プログラミング Visual C++.NET Vol.2 活用編
 第28章 インターネット通信の基礎 313 ページ
 28.3.2 MFC の Winsock クラス


参考になるコードを探したが,その範囲でわかりやすかったのがここ.
http://www.katto.comm.waseda.ac.jp/~katto/
http://www.katto.comm.waseda.ac.jp/~katto/Class/GazoTokuron/code/socket.html
但し,そのままのコードではコンパイルエラーなどが少しあったので修正.
また,#ifdef _MSC_VER で一つのコードに.
sock_tcp.zip
VC 6 と DS115j でビルドし動作を確認.
ここまでの範囲では,クライアントからサーバに固定の文字列を送信.
LAN 内の PC と NAS などで相互に確認済み.


tcp_s.cpp のコードを一部修正.
 char buffer[BUFFER_SIZE+10]; // +10 の大きさに
 受信部分で
  while(1) {
    memset(&buffer,0,sizeof(buffer)) ; // バッファのクリアを追加
    numrcv = recv(dstSocket, buffer, BUFFER_SIZE, 0);
    …
    }


サーバ側の tcp_s.exe を実行.
次の様な html を用意して,ブラウザで開く.
 <!DOCTYPE html>
   <html lang=”ja” >
   <head >
    <meta charset=”UTF-8″ />
    </head>
   <body >
    <form action=”http://localhost:9876/” method=”post” enctype=”multipart/form-data”>
     <input type=”file” name=”fname”>
     <input type=”submit” value=”upload”>
     </form>
    </body>
   </html>
 何も指定せずに「upload」.


C:\…\Iwao>”C:\…\tcp\tcp_s\Release\tcp_s.exe”
Waiting for connection …
Connected from 127.0.0.1
received: POST / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, appli
cation/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/ms
received: word, */*
Referer: http://ds115j/Test/test_up/test_up.htm
Accept-Language: ja
Content-Type: multipart/form-data; boundary=—————————7e13a71ce4098a
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows N
received: T 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Host: localhost:9876
Content-Length: 195
Connection: Keep-Alive
Cache-Control: no-cache
 
—————————
received: –7e13a71ce4098a
Content-Disposition: form-data; name=”fname”; filename=””
Content-Type: application/octet-stream
  
  
—————————–7e13a71ce4098a–
  
  
C:\…\Iwao>


ClassicASP や ASP.NET でのファイルのアップロード
 ASP を使用して Web サーバーにファイルをアップロードする方法
 IIS7 ファイルアップロード用ページを簡単に作成する方法
ASP.NET の方は動作確認済み.


http://www.geekpage.jp/
http://www.geekpage.jp/programming/winsock/

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

IIS+PHP-3

さらに次の様な exe の起動.
   exec (change_sp(“./imotowgl”)) ;
あまり関係ないが php と同じ場所に imotowgl と IMOtoWGL.exe が存在する.


この指定では,DS115j ではうまく動作しているが IIS 環境では起動できないみたい.
次の様に exe を付けるか,大文字などファイル名を正しく指定する必要があるみたい.
   exec (change_sp(“./imotowgl.exe”)) ;
   exec (change_sp(“./IMOtoWGL”)) ;
change_exe 関数を追加することに.


php の動作を確認していて,何かうまく動作しない.
と思ったら,「既定のドキュメント」の設定.


change_exe は,
  function change_exe ($path) {
     $exe = $path ;
     if (DIRECTORY_SEPARATOR == ‘/’) { $exe = strtolower($exe) ; }
     else { $exe = $exe . “.exe” ; }
     $exe = str_replace (“/”,DIRECTORY_SEPARATOR,$exe) ;
     return $exe ;
     }


さらに実行ファイルの場所も,相対位置ではなく change_cmd 内で求める様に変更.
 <?php
   include ($_SERVER[“DOCUMENT_ROOT”] . “/…/i_lib.php”) ;
 // exec (change_sp(“./bin/DrawNow”)) ;
   exec (change_cmd(“DrawNow”)) ;
   readfile(“./drawnow.htm”) ;
   ?>
動作は,DrawNow

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

IIS+PHP-2

先日 php のインクルードなどに PHP_OS を利用していたが,
  $base = “/…/web” ;
  if (PHP_OS == ‘WINNT’) { $base = “c:/…/web” ; }
  else { $base = “/…/web” ; }
  include ($base . “/_lib/…/log.php”) ;
$_SERVER[“DOCUMENT_ROOT”] を見つけたので,
  include ($_SERVER[“DOCUMENT_ROOT”] . “/_lib/…/log.php”) ;


他に,実行ファイルは OS に合った指定が必要な様で,
 <?php
   include ($_SERVER[“DOCUMENT_ROOT”] . “/…/log.php”) ;
   logging () ;
   exec (change_sp(“./bin/DrawNow”)) ;
   // …
   ?>
Synology/DrawNow/

IIS 7/DrawNow/

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

DS115j 3D データ読込

今度は,imo(obj を拡張した 3D データ)の読込み.


次の様なコードで …/…imo  -nan -nan -nan となってしまう.
   GonsA ga = ::OBJ_ToGonsA(imoFile.c_str()) ;
   std::tout << imoFile << _T("\t") ;
   std::tout << ::V3_To_tstring(::GonsA_GetVolume(ga)) << std::endl ;


単純に読込んで,保存するのは OK .
   v_tstring txtAry = ::LoadTextFile(imoName.c_str()) ;
   ::SaveTextFile((imoName+_T(“.mox”)).c_str(),txtAry) ;
3D データとして取り込み,出力すると,全体的に -nan や nan となる.
   GonsA gt = ::OBJ_ToGonsA(imoName.c_str()) ;
   ::GonsA_ToOBJ(gt,_T(“./7_boxes.mox”)) ;


次の様にすると
   long v1 = ::ttoi4(_T(“10”)) ;
   long v2 = ::ttoi4(_T(“10 “)) ;
   long v3 = ::ttoi4(_T(“10.5”)) ;
   double f1 = ::ttof (_T(“10”)) ;
   double f2 = ::ttof (_T(“10 “)) ;
   double f3 = ::ttof (_T(“10.5”)) ;
   double d1 = ::ttod (_T(“10”)) ;
   double d2 = ::ttod (_T(“10 “)) ;
   double d3 = ::ttod (_T(“10.5”)) ;
   Vl3 v(v1,v2,v3) ;
   Vd3 f(f1,f2,f3) ;
   Vd3 d(d1,d2,d3) ;
   std::tout << ::V3_To_tstring(v) << std::endl ;
   std::tout << ::V3_To_tstring(f) << std::endl ;
   std::tout << ::V3_To_tstring(d) << std::endl ;
本来は,
  10 10 10
  10 10 10.5
  10 10 10.5
DS115j では,
  10 10 10
  0 0 0
  -nan -nan -nan


内部的に呼んでいるのは,strtol と strtod など.


2017/06/20
atof も同様.
sscanf を利用することで対応.
  double ttod_scan (LPCTSTR str) {
     double value = 0 ;
     sscanf(str,_T(“%lg”),&value) ;
     return value ;
     }
 
原因と言うか対応は次の内容と同じなのかとは思うが,
 個人的に理解できるレベルには達していない.
Armadillo-840でstrtodを使った浮動小数点文字列の変換が出来ない

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

DSM 更新で…

DSM を更新した影響か? g++ などが通らなくなってしまった.


sudo -i
 
mkdir -p /volume1/@entware-ng/opt
ln -sf /volume1/@entware-ng/opt /opt
 
wget -O - http://pkg.entware.net/binaries/armv7/installer/entware_install.sh | /bin/sh
 
root@DS115j:/etc# cat rc.local
#!/bin/sh
#
/bin/ln -sf /volume1/@entware-ng/opt /opt
/opt/etc/init.d/rc.unslung start
#
 
/root/.profile
. /opt/etc/profile
 
reboot

sudo -i
opkg -v


また,更新してしばらく?は,何か動作が安定していない気がする.
php や c++ での動作が何か変?

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

DS115j std::tostringstream

DS115j で,次の様なコードの str が “123” にならない(”0″ になる).


 {
   double checkValue = 123 ;
   tstring str ;
   std::tostringstream strBuf ;
   {
     strBuf << checkValue ;
     str = strBuf.str() ;
     }
   // …
   }


sprintf を利用することで対応.
 {
   std::string str ;
   tstring fmt = _T(“%.”) + ::To_tstring(p) + _T(“f”) ;
   str.resize(512,0) ;
   sprintf(&str[0],fmt.c_str(),v) ;
   // …
   }

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

Synology g++ DrawLog.cpp

前回 mac 上で動作する様にしたものを DS115j に.
CPATH などの設定も mac と同じ様な感じで指定.


php から呼び出し,実行ファイルが起動していることは確認できていた.
 DSM の「リソース モニタ」-「プロセス」で確認.
が,結果が正しく表示されない.
ssh で接続しての起動では正しく動作している.
原因は,デバッグ用にデータをダンプしていたディレクトリのアクセス権の設定.
書き込み可能にして OK

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

g++ DrawLog.cpp

今まで xcode を利用していたが,他の PC からビルドするために…


コードは次の様なもの.ほとんどの動作はi_DrawLG.hxx 内に.
 // カレントのファイルを成型してファイルに出力
 #include “i_DrawLg.hxx”
 #include <iostream>
 int _tmain (int argc,TCHAR* argv[])
 {
   _tsetlocale(LC_ALL,_T(“”)) ;
   {
    std::tout << ::GetCWD() << std::endl ;
    }
   tstring logPath = _T("./") ;
   #ifdef _WIN32
     logPath = ::Get_i_Tools_tmp() ;
   #endif
   ::PL_DrawLog(logPath) ;
   return 0 ;
   }
 //———————–
 #include "MessBar.cxx"


次の様に -I で指定すれば,include が機能するのは知っていたが…
 g++ DrawLog.cpp -I/Users/…/__CPR_ -I/Users/…/__Iwao
環境変数を利用する様に
 export CPATH=/Users/…/__CPR_
 export CPATH=/Users/…/__Iwao:$CPATH
これらをスクリプトファイルに登録.
 呼出し元にも反映させるには bash env.sh ではなく
  source env.sh とする必要があるらしい.
sh ファイルを MIFES で編集していて,微妙にうまく動作していない.
 原因は改行コードで,「LF」で保存.
これで g++ DrawLog.cpp としてビルドできる様になった.


実行すると,Segmentation fault: 11.
xcode でもテストしてなかったのでデバッグすると,
 readdir で EXC_BAD_ACCESS .
ここは _WIN32 では通らないのでデバッグが不十分な部分.
 原因は,与えているファイルが
  ディレクトリでなかった.
  ファイルが存在していなかったこと.
コードを修正して OK .

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

Synology NAS で gcc

2022/06
https://dev.mish.work/wordpress/2022/06/15/ds116-entware/


2022/03
https://dev.mish.work/wordpress/2022/03/13/ds220-setup-4-opkg/


ssh などで接続した DS115j 上で, gcc などを使える様にするために…
ipkg や Opkg が必要らしい.
Install on Synology NAS
日本語で説明されている所があったので,参考にさせてもらった.
 2016/06/29 Synology DS216j Entware-ng 導入


g++ でコンパイルして ./a.out を生成.
exec.php を開くと,
php から a.out の呼び出し


ASUSTOR NAS
QNAP NAS

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

EnumFilesTree で無限ループ

フォルダ以下の全てのファイルを列挙する関数

v_tstring	EnumFilesTree	(LPCTSTR path)
{
	v_tstring	foundFiles = ::EnumFiles(path) ;
	v_tstring	foundFolds = ::ExtractFolders(foundFiles) ;
	for (size_t index=0 ; index<foundFolds.size() ; index++) {
		tstring		subFold = foundFolds[index] ;
		v_tstring	chFiles = ::EnumFiles(subFold.c_str()) ;
		v_tstring	chFolds = ::ExtractFolders(chFiles) ;
		foundFolds.insert(foundFolds.end(),chFolds.begin(),chFolds.end()) ;
		foundFiles.insert(foundFiles.end(),chFiles.begin(),chFiles.end()) ;
		}
	return	foundFiles ;
	}

今まで特に問題なく動作していたが,
先週末 VC 14 i3DV のデバッグ版を実行すると無限ループに.
Release 版や,VC 12 のデバッグ版などでは OK .


昨日は,別の PC 環境だったため再現せず.


今日デバッガを使用して調査すると,
 フォルダの「作成日時」が正しくない.
 /wordpress/dev/2016/09/15/
そのため,_wstat64 が正しく帰ってこない.


v_tstring	EnumFiles	(LPCTSTR path_,const bool skipDot=true)
{
	tstring	path = ::Path_DelLastSP(path_) ;
	if (!File_IsDirectory(path.c_str()))	{
		path = ::Path_GetDir(path) ;
		}
	v_tstring	foundFiles ;
	#if		defined	__GNUC__
		foundFiles = ::EnumFiles_GNUC	(path,skipDot) ;
	#elif	defined	_MFC_VER
		foundFiles = ::EnumFiles_MFC	(path,skipDot) ;
	#elif	defined	_MSC_VER
		foundFiles = ::EnumFiles_MSC	(path,skipDot) ;
	#endif
	return	foundFiles ;
	}

ここの,File_IsDirectory(…) で,stat を利用している.


次の様に ::GetFileAttributes(…) の判断を追加.

	if (!::File_IsDirectory(path.c_str()))	{
		#if	(_MSC_VER == 1900)
		{
			if (!::FA_Is_Directory(path)) {
				path = ::Path_GetDir(path) ;
				}
			}
		#else
		{
			path = ::Path_GetDir(path) ;
			}
		#endif
		}

enumfile.hxx

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

Eclipse での設定など

ndk-build でのエラー
Compile thumb : ~ <= ~.c が表示されない.
  Android.mk の記述ミス.LOCAL_SRC_FILE になっていた(S がなかった).
TextView に setText などをするとエラーになる.
  setContentView(R.layout.activity_main) が呼ばれていなかった(コメントになっていた).
cpp として作成したものの利用で実行時エラー
  原因はわからず.c のファイルとして書換えてビルドで通った.


undefined reference to ‘sysinfo’
  Using sysinfo in Android NDK を見つけたが,使い方がわからず.
    undefined reference to ‘__NR_sysinfo’ となってしまう.


C/C++ プロジェクトのインクルードパスの設定
  プロジェクトの「プロパティ」,「C/C++ ビルド」-「設定」-「ツール設定」-「GCC ~ Compiler」-「インクルード」.
    全プロジェクトで有効にするには環境変数としての登録が必要?

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

MinGW インストール

Android の開発環境を用意しようとしていて,
Pleiades – Eclipse プラグイン日本語化プラグイン をインストールまでは行っていた.
pleiades-e4.2-ultimate-32bit-jre_20130303.zip
以前インストールした(展開)時は,ファイル名の長さの制限で引っかかって,インストールまでで中断していた.


が,よくわからない.
その中に MinGW があったので,そこから,…


~\MinGW\bin に gcc.exe などがあったので,
テスト用の Hello.c を作成して,コンパイルすると a.exe はできた.


c:\~\My Documents\Temp\Test> type T_Hello.c
#include <stdio.h>
int main (void) {
  printf(“hello\n”) ;
  return 0 ;
  }
 
c:\~\My Documents\Temp\Test> C:\pleiades\eclipse\mingw\bin\gcc.exe T_Hello.c
 
c:\~\My Documents\Temp\Test> dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 7C5D-D1D9 です
c:\~\My Documents\Temp\Test のディレクトリ
2013/06/20 14:19 .
2013/06/20 14:19 ..
2013/06/20 14:19 49,177 a.exe
2013/06/20 14:07 78 T_Hello.c
2 個のファイル 49,255 バイト
2 個のディレクトリ 114,850,582,528 バイトの空き領域
 
c:\~\My Documents\Temp\Test> a
hello
 


これでは使い勝手が悪いので調べると,MSYS が使えそう.
けど MinGW フォルダには見当たらない.
MinGw Getting Started のリンク mingw-get-inst より,もう一度インストール.


MinGW Shell で開いてくるのは,C:\MinGW\msys\1.0\home\Iwao
 
C:\>tree \MinGW\msys\1.0\home
フォルダ パスの一覧
ボリューム シリアル番号は 7C5D-D1D9 です
C:\MINGW\MSYS\1.0\HOME
└─Iwao
  └─Temp
    └─Test


MSYS コンソール内で,
  ネットワーク上のファイルは,//DevXP/C_Drive/…/c_src/
  ls c:
  ls \\
  ls \\\\DevXP\\C_Drive
  \\ と / は,等価?
  more ではなく less


C++ のコード(std::cout<<“Hello CPP” << std::endl ;)をコンパイルすると,
$ gcc testcpp.cpp
C:\~\Temp\ccYlk1I9.o:testcpp.cpp:(.text+0x19): undefined reference to `std::cout’
C:\~\Temp\ccYlk1I9.o:testcpp.cpp:(.text+0x1e): undefined reference to `std::basic_ostream …

C:\~\Temp\ccYlk1I9.o:testcpp.cpp:(.text+0x6a): undefined reference to `std::ios_base::Init::Init()’
collect2: ld はステータス 1 で終了しました
  gcc ではなく,g++ を利用するみたい.
 
また,出来上がった C++ の exe は,MSYS コンソールの外では,
—————————
TestCPP.exe – コンポーネントが見つかりません
—————————
libgcc_s_dw2-1.dll が見つからなかったため、このアプリケーションを開始できませんでした。
アプリケーションをインストールし直すとこの問題は解決される場合があります。
—————————
OK
—————————


2013/06/25
Eclipse を起動して,
 「ファイル」-「新規」-「C++ プロジェクト」,「Hello World …」-「MinGW GCC」.
ビルド,実行で,
Eclipse Hello MinGW

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

FindNoCase

同じ関数を作ってしまったので,...
CharFnc.hxx より
//*******************************************************************************
// 関数名 :大文字/小文字を区別せずに検索
// 作成日 :’11/09/07
//*******************************************************************************
inline
int FindNoCase (LPCTSTR str1,LPCTSTR str2)
{
  CString fStr1 = str1 ;
  int fIndex = fStr1.Find(str2) ;
  if (fIndex >= 0) { return fIndex ; } // 大文字/小文字を区別して見つかった?
  CString fStr2 = str2 ;
  fStr1.MakeLower() ;
  fStr2.MakeLower() ;
  return fStr1.Find(fStr2) ; // 大文字/小文字を区別せずに(小文字にして)検索
  }

他にも,
PathName.hxx
PathName.hxx
//*******************************************************************************
// 関数名 :ファイル拡張子取得(text.DAT->dat) 小文字で
// 作成日 :’11/06/09
//*******************************************************************************
inline
CString GetFileExtLow (LPCTSTR pathName)
{
  CString ext = ::GetFileExt(pathName) ;
  ext.MakeLower() ;
  return ext ;
  }


StringFn.hxx

stringfn.hxx

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