ホーム » メモ (ページ 19)

メモ」カテゴリーアーカイブ

2025年6月
1234567
891011121314
15161718192021
22232425262728
2930  

カテゴリー

アーカイブ

ブログ統計情報

  • 116,181 アクセス


‘THIS_FILE’ がシンタックスエラーを…

今まで通っていたプロジェクトで,
  ComPrj03.cpp
  c:\…\memory(16) : error C2061: 構文エラー : 識別子 ‘THIS_FILE’ がシンタックスエラーを起こしました。
  c:\…\memory(17) : error C2091: 関数は関数を返せません。
  c:\…\memory(17) : error C2809: ‘operator new’ に仮引数リストがありません。
  c:\…\memory(20) : error C2954: テンプレートの定義はネストできません。
  cl.exe の実行エラー
  ComPrj03.obj – エラー 4、警告 0


ソースの先頭付近に #include <memory> を追加.
  #include “StdAfx.h”
  #include “ComPrj00.hpp”
  #include <memory>
 


2019/01/18

--------------------構成: MkZIP2 - Win32 Release--------------------
コンパイル中...
MkZIP2.cpp
リンク中...

MkZIP2.exe - エラー 0、警告 0
--------------------構成: MkZIP2 - Win32 Debug--------------------
コンパイル中...
MkZIP2.cpp
c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: 構文エラー : 識別子 'THIS_FILE' がシンタックスエラーを起こしました。
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 の実行エラー

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

#include “stdafx.h”
#include “MkZIP2.h”
#include <ShlObj.h>
#import <Shell32.dll> // named_guids
//#include <memory>


エラーになるのはデバッグ版のビルド.リリース版では通る.
#include <memory> を有効に.


2023/03/24
#define new DEBUG_NEW より後にインクルードしているとうまくない error C2061 , C2091 , C2809 , C2556

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

~iDocText でダウン

先日作成した TextureToPath 関係でダウンする様になってしまった.
場所は,iDocText のデストラクタ付近.
呼出し元をたどると,#pragma omp parallel for .


TextureCopy::GetDrawName に #pragma omp critical (TextureCopy_GetDrawName) を追加.

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

LAN-GTJU3H3 追加

LAN-GTJU3H3 を追加.
何が悪いのかわからないが 100 M で接続されているみたい.今の用途では遅さはそれほど気にならない.
付属のマニュアルはちょっと古いみたいで,ここからマニュアルを参照.

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

時刻の同期

6/20 に HDL-Z2WM2C2 を追加した.
ソースファイルの保管のサーバとしての利用で,Win7 USB 2 HDD と比べても遜色ない.
ひとつ気になることが,思っていたよりファンの音がうるさい.


先日,クライアントの PC と WSS で,時間が少しずれていたので time.windows.com で時刻を合わせた.
今日時刻を見てみると 10 秒位の差ができてしまっている.
もう少し精度が欲しかったので検索すると,
インターネット時刻機能のポーリング間隔を調整する方法
Windowsの時計がずれる / 自動で正確に合わせる小技 (Windows 7/8.1編)
これらを参考にさせてもらって,1 日に 1 回程度の設定とした.

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

Polymorphism

class iDocCSV1 : public iDocText {

virtual long GetFieldNo (c_tstring& fieldName) const { return FNoNOP ; }

} ;
c_tstring fieldName となっていた.


TextureTo_1::MakeCSV1 でタプルクォーテーションでうまく括られない.閉じる ‘\”‘ が付加されない.
   da.push_back(::QuotM_Add_Auto( GetPath () ) ;
原因はよくわかってないが,LPCTSTR 版を利用することで対応.
   da.push_back(::QuotM_Add_Auto( GetPath ().c_str()) ) ;
MakeCSV1 を切り出してコンソール AP としてテストしたが,期待した動作となり原因は掴めてない.


2014/06/25
また次の様なコードで,STL 版ではうまく動作していない.
{
tstring str ;
str += tt1->GetName() + _T(“\r\n”) ;
str += tt1->GetPath() + _T(“\r\n”) ;
str += tt1->GetPathPNG()+ _T(“\r\n”) ;
str += tt1->GetPathTGA()+ _T(“\r\n”) ;
m_TexPath1 = str.c_str() ;
}
MFC 版では OK .
{
CString str ;
str += tt1->GetName ().c_str() + CString(_T(“\r\n”)) ;
str += tt1->GetPath ().c_str() + CString(_T(“\r\n”)) ;
str += tt1->GetPathPNG ().c_str() + CString(_T(“\r\n”)) ;
str += tt1->GetPathTGA ().c_str() + CString(_T(“\r\n”)) ;
m_TexPath1 = str ;
}


2014/06/27
また,::String_Join_Line でうまく結合されなかった.
デバッガで調べると,サイズは確保されいる.メモリの内容をよーく見てみると,途中に ” が入っている.
原因は,MFC を利用しない方法で書き直した ::DropFilesTo のバグ.
ファイル名の最後に余分な ‘\0’ が付加されていた.

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

NICONI SOLID

ニコニ立体で表示可能な OBJ のメモ
データは 100x100x100 の立方体.Cube_obj.zip
いろいろいじってたら,立方体があるのはわかる様になった.
(背景の色を指定して,スケーリングを 0.1 ,視野角を大きく)

どうも,大きすぎる様なので -1 ~ 1 の範囲の立方体に編集.Cube_2.zip

テクスチャがうまく張り付かないので,OBJ や MTL をいろいろ編集…
MTL 内の newmtl とそれに続く名称との間のスペースが 1 つでないとうまくないみたい.Cube_3.zip


はっきりわからないが,4 を超える多角形の面が表示できない?


i_S_asZ

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

VC 11 , 12

AtlGetCommCtrlVersion が,GetCommCtrlVersion になっている.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlbase.h 7505:
   inline HRESULT AtlGetCommCtrlVersion(
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\winutil.cpp 243:
   HRESULT GetCommCtrlVersion(


VC 12 の標準のインストールでは MBCS.exe が作成できない.
MSDN マルチバイト文字セット (MBCS) のサポート


—— ビルド開始: プロジェクト:ccVer, 構成:Debug Win32 ——
ccVer.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
c:\program files\windows kits\8.1\include\um\winnt.h(340):
  error C2146: 構文エラー : ‘;’ が、識別子 ‘PVOID64’ の前に必要です。
c:\program files\windows kits\8.1\include\um\winnt.h(340):
  error C4430: 型指定子がありません – int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
c:\program files\windows kits\8.1\include\um\winnt.h(12333):
  error C2146: 構文エラー : ‘;’ が、識別子 ‘Buffer’ の前に必要です。
c:\program files\windows kits\8.1\include\um\winnt.h(12333):
  error C4430: 型指定子がありません – int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ==========
DX90SDK\Include が含まれていたのが原因.


c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(206):
  warning C4003: マクロ ‘round’ に指定された実引数の数が少なすぎます。
c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(206):
  error C2059: 構文エラー : ‘(‘
c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(206):
  error C2062: 型 ‘double’ は不要です。
c:\program files\microsoft visual studio 12.0\vc\include\xtgmath.h(224):
  fatal error C1070: ソース ファイル ‘c:\…\vc\include\xtgmath.h’ 中で #if と #endif が対応していません。
Scale.hxx 等に定義されている #define round(v,p) … が影響していると思われる.
C99 になったことによる影響?


_MSC_VER はソースの先頭でも定義されているが,_MFC_VER は Afx.h の後でないと正しく取れない?
  よく考えれば当然のこと?


MFC 11 で CFileStatus が変更された.

  MFC 10 では,
    struct CFileStatus
    {
      CTime m_ctime;          // creation date/time of file
      CTime m_mtime;          // last modification date/time of file
      CTime m_atime;          // last access date/time of file
      ULONGLONG m_size;       // logical size of file in bytes
      BYTE m_attribute;       // logical OR of CFile::Attribute enum values
      BYTE _m_padding;        // pad the structure to a WORD
      TCHAR m_szFullName[_MAX_PATH]; // absolute path name
    #ifdef _DEBUG
      void Dump(CDumpContext& dc) const;
    #endif
    };

  MFC 11
    struct CFileStatus
    {
      CTime m_ctime;          // creation date/time of file
      CTime m_mtime;          // last modification date/time of file
      CTime m_atime;          // last access date/time of file
      ULONGLONG m_size;       // logical size of file in bytes
      DWORD m_attribute;      // logical OR of CFile::Attribute enum values
      TCHAR m_szFullName[_MAX_PATH]; // absolute path name
    #ifdef _DEBUG
      void Dump(CDumpContext& dc) const;
    #endif
    };

Visual Studio 2012 の更新プログラムの概要
Visual Studio 2012 の更新プログラム 4
Download Center Visual Studio 2012 Update 4


VC 2012 で作成した exe は,Win XP で実行できない?
Visual Studio 2012 で Windows XP をターゲットとする Visual C++ アプリケーションを作成する方法
Wikipedia Microsoft Visual C++


Visual Studio 2012 更新プログラム 4 の Visual C++ 再頒布可能パッケージ
Visual Studio 2013 の Visual C++ 再頒布可能パッケージ


プロジェクトをサーバにコピーして,VC 8 でビルドすると
  cl : コマンド ライン error D8022 : ‘\\devs\…\ArcEdit\Debug.080\RSP0000264523920.rsp’ を開けません
ローカルのプロジェクトは OK.
また,VC 6 なども C2039 はあるが,それなりに通る.
  \\devs\…\helpvsty.hxx(57) : error C2039: ‘AtlGetCommCtrlVersion’ :
     ‘`global namespace” のメンバではありません。
  これは,#define GetCommCtrlVersion AtlGetCommCtrlVersion としている所を,関数にして回避.
    … GetCommCtrlVersion (…) { return AtlGetCommCtrlVersion (…) ; }


VC 7.1 と VC 8 で,ネットワーク上のプロジェクトをビルドするとうまくない様なので,中間ファイルの指定を変更.
  .\$(ConfigurationName) を c:\Temp\$(ProjectName)\$(ConfigurationName) としてみた.
  これにより,rsp や obj などが C:\Temp\…\Debug\ 以下になりうまく通る.
検索すると,.\$(ConfigurationName)\ の様に最後に ‘\’ を付ければ通るとのこと.
  Error D8022 – can’t open .RSP file


2014/04/17
今までバックアップを取ったりする時に不要なファイルを消していたが,プロジェクトの設定などを変更してみた.
中間ディレクトリとデバッグ版の出力ディレクトリを c:\Temp\$(ProjectName)\$(ConfigurationName)\ に.
VC 10 以降で,フォールバック位置を指定(sdf , ipch の位置の指定).


VC 11 で,
  LibHasp_Windows.lib(wurzl37.obj) : error LNK2026: モジュールは SAFESEH イメージには安全ではありません。
    「リンカ」-「詳細設定」-「安全な…」の「はい (/SAFESEH)」をクリア.

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

C1083 msxml.dll

WinXP + VC 2005 環境のプロジェクトを,Win7 + VC 2008 でビルドすると,
\\devxp\…\xml_ms_.hxx(15) : fatal error C1083: タイプ ライブラリ ファイルを開けません。
‘msxml.dll’: No such file or directory
検索すると,
XML file parsing in Visual Studio 2008 & Windows 7


2014/08/19 追記
Win8 + VC 2012 でビルドすると
  \\DevS\…\Xml_MS_.hxx(329): error C2039: ‘CLSID_DOMDocument’ : ‘MSXML2’ のメンバーではありません。
これで良いのかはわかってないが,#define CLSID_DOMDocument CLSID_DOMDocument60 を追加.
  #if (_WIN32_WINNT >= 0x0600)
    #import <msxml6.dll> named_guids
    #define MSXML MSXML2
    #define CLSID_DOMDocument CLSID_DOMDocument60
  #else
    #import <msxml.dll> named_guids
  #endif
 
2019/06/29 Win10 VC 2005 で C1083 msxml.dll


2019/01 C++ と STL の範囲で書き直し

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

three.js

three.js の動作環境の作成のメモ
three.js の左の github から.
Usage の Download the minified library and …. の minified library を右クリックするなどしてダウンロード.
C:\Users\Public\Documents\WebGL\Three_js\three.min.js として保存.
This code creates a scene, …… in the document.body element. の下のスクリプトを Test3js.htm などとして保存.
その html の前の方と後ろの方を編集.
<!DOCTYPE html>
<html lang=”ja”>
<head><meta charset=”UTF-8″></head>
<body>
<script src=”three.min.js”> </script>
<script>
var camera, scene, renderer;

function init() {

renderer.render( scene, camera );
}

</script>
</body>
</html>


107SH で,192.168.x.x/Test/…/Test3js.htm にアクセスすると,

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

頂点法線の計算

今まで GL_FLAT で処理していたので面の法線を利用していた.
そのため,既に法線の情報が設定されたデータでうまく表示できてないものがあった.
GL_FLAT での表示
glShadeModel(GL_SMOOTH) として,頂点に対して法線を設定することによりそれなりに表示する様にはなった.
GL_SMOOTH での表示


これらのデータの様に,頂点の法線を求める必要が出てきた.
ここ(スムージング角度)を参考にさせてもらい,何とかそれなりに表示できる様になった.
頂点の法線ベクトルを利用した表示


gonsfnc.hxx

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

String_Split

    MB MFC MB STL WC MFC WC STL
99103040 5714 0 20 0 70
99103036 14192 10 130 10 380
99103032 27636 10 400 20 1400
99103051 41128 20 900 20 3200
99103026 65388 50 2400 50 7200

単位は m sec

表では MFC と表現しているが,実際は CStringArray を利用している程度.
ちょっと意外だったのが,STL のコードで,UNICODE 版が MBCS 版の 3 倍以上になってしまっている.


STL を利用しているコードは以下の通り.
std::vector<tstring> String_Split (const tstring& str_,LPCTSTR sp=_T(" \r\n"))
{
  std::vector<tstring> strAry ;
  tstring str = str_ ;
  {
    tstring::size_type spPos = tstring::npos ;
    while ((spPos=::String_FindFirstOf(str,sp)) != tstring::npos) {
      if (str.empty()) { break ; }
      TCHAR fc = str[0] ;
      if (fc == _T(‘\"’) || fc == _T(‘\”)) { // "—" or ‘—‘
        if ((spPos=::String__Find(str,fc,1)) == tstring::npos) {
          break ;
          }
        if ((spPos = ::String_FindFirstOf(str,sp,spPos)) == tstring::npos) {
          break ;
          }
        }
      tstring splitS = str.substr(0,spPos) ;
      strAry.push_back(splitS) ;
      str = str.substr(spPos+1) ;
      if (str.empty()) { break ; }
      }
    if (!str.empty()) {
      strAry.push_back(str) ;
      }
    }
  return strAry ;
  }


String_Join も同様だが,MFC 版 StringArrayToLine1 の 1 割程度なので,このままとする.
MFC 版 StringArrayToString は十分速い.


StrAryFn.hxx

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

3DS

3DS 出力で正しくないのが生成されたので,バイナリを解析した時のメモ


http://www.dcs.ed.ac.uk/home/mxr/gfx/3d/3DS.spec
http://www.martinreddy.net/gfx/3d/3DS.spec

Chunk ID 2  
データ長 4 この次のデータの長さ + 6
データ    

 
4D4D
  3D3D
    AFFF
      A000        名称
      A020   15
        0011  9    RGB
    AFFF 
    …
    4000          名称
      4100    
        4110      頂点情報 ( WORD 頂点数 , [ float x , y , z ] )
        4140      テクスチャ ( WORD 点数 , [ float x , y ] )
        4160      
        4120      面情報 ( WORD 面数 , [ WORD 3 頂点のインデックス , WORD 面の情報 ] )
          4130    材質名 , WORD 面数 , [ WORD 面のインデックス ]
          4130        
          …
    B000      
      …


頂点数が WORD を超えていたのが原因.
PgonsA_To3DS の objIs1==TRUE で,vp3Ary.GetCount() >= 0x10000 の時,PgonsA_To3DS (…,FALSE,…) .

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

ダイアログでのEyeChange

CStatic 内に表示するには,this ではなく &m_Image とする.
// u_Zoom. Init(this,&u_Scale) ;
   u_Zoom. Init(&m_Image,&u_Scale) ;
// u_EyeChg. Init(&m_Image) ;
   u_EyeChg. Init(this) ;
   Eye eye(Eye::StdR) ;
   u_EyeChg. SetEye (eye) ;
   u_EyeChg. SetExtent(doc->PartsA_.GetExtent()) ;
   u_EyeChg. Set_MouseEyeChange(TRUE) ;
// u_Zoom. Init(this,&u_Scale,&u_EyeChg) ;
   u_Zoom. Init(&m_Image,&u_Scale,&u_EyeChg) ;
MButton , MouseWheel では,InvalidateRect などが必要.
 void CAboutDlg::OnMButtonDown(UINT nFlags, CPoint point)
 {
   if (u_EyeChg. Event(GetCurrentMessage())) { return ; }
   if (u_Zoom. Event(GetCurrentMessage())) { InvalidateRect(NULL) ; return ; }
   CDialog::OnMButtonDown(nFlags, point);
  }
 BOOL CAboutDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
   if (u_EyeChg. Event(GetCurrentMessage())) { return TRUE ; }
   if (u_Zoom. Event(GetCurrentMessage())) { InvalidateRect(NULL) ; return TRUE ; }
   return CDialog::OnMouseWheel(nFlags, zDelta, pt);
  }

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

C# のコードを C++.NET で…

MSDN にあるサンプルを VC++2008 でビルドする.
MSDN 四角形内にテキストを折り返して描画する


新規プロジェクトで「Windows フォーム アプリケーション」.
「新規プロジェクト」-「Windows フォーム アプリケーション」
Paint のハンドラを追加.
Paint ハンドラの追加


private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
/*
  string text2 = “Draw text in a rectangle by passing a RectF to the DrawString method.”;
  using (Font font2 = new Font(“Arial”, 12, FontStyle.Bold, GraphicsUnit.Point))
  {
    Rectangle rect2 = new Rectangle(30, 10, 100, 122);
    // Specify the text is wrapped.
    TextFormatFlags flags = TextFormatFlags.WordBreak;
    TextRenderer.DrawText(e.Graphics, text2, font2, rect2, Color.Blue, flags);
    e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(rect2));
  }
*/

  String^        text2 = “Draw text in a rectangle by passing a RectF to the DrawString method.”;
  Drawing::Font^     font2 = gcnew    Drawing::Font(“Arial”, 12, FontStyle::Bold, GraphicsUnit::Point) ;
  Drawing::Rectangle^    rect2 = gcnew    Drawing::Rectangle(30,10,100,122) ;
  TextFormatFlags        flags = TextFormatFlags::WordBreak ;
  TextRenderer::DrawText(e->Graphics,text2,font2,*rect2,Color::Blue,flags) ;
  e->Graphics->DrawRectangle(Pens::Black,*rect2) ;
}


RECT または CRect にあたるものは,Drawing::Rectangle .
ここで利用している Font は Drawing::Font としないとエラーになる.
  c:\…\drawt_2\Form1.h(87) : error C2061: 構文エラー : 識別子 ‘Font’
DrawText などの Rectangle はハンドルではなく実体.


2013/11/05
C# の文字列の前の ‘@’
リテラル文字列


MFC での文字列の変数に対する += .
  CString str ;
  str += _T(“123”) ;
C++/CLI で System::String は可能であるが,C# の string ではエラーとなるみたい.


2013/11/06
C# で g.Dispose() ;
  C++ では delete g ;
Graphics.Dispose メソッド

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

LAN-RPT01BK 追加

LAN-RPT01BK を追加.
設置場所が悪いのか,ちょっと不安定な気がする.
スマートフォンなので詳細がわからないが,どうも途切れることがある様な感じ.
導入前は場所によりつながらなかったので,それよりは良くなったと思われる.


その後,ノート PC での速度が遅くなったみたいで,結局外す事にした.
また,アクセスポイントの位置を 1m 程度ずらすことにより,いい感じにカバーできるようになった.


LAN-RPT01BK

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

C2061

既存のプロジェクトで,::To_tstring(const P2&…) を追加したら,
——————–構成: BLCombi – Win32 Debug——————–
コンパイル中…
ComPrj01.cpp
c:\…\vc98\include\memory(16) : error C2061: 構文エラー : 識別子 ‘THIS_FILE’ がシンタックスエラーを起こしました。
c:\…\vc98\include\memory(17) : error C2091: 関数は関数を返せません。
c:\…\vc98\include\memory(17) : error C2809: ‘operator new’ に仮引数リストがありません。
c:\…\vc98\include\memory(20) : error C2954: テンプレートの定義はネストできません。
c:\…\…..\blocklsv.cpp(398) : error C2678: 二項演算子 ‘+’ : 型 ‘class std::basic_string …’ の
  左オペランドを扱う演算子は定義されていません。(または変換できません)(新しい動作; ヘルプを参照)
cl.exe の実行エラー
ComPrj01.obj – エラー 5、警告 0


本来の対応は別の所にありそうだが,ComPrj01.cpp の先頭に #include <memory> を追加した.
  #include “StdAfx.h”
  #include “ComPrj00.hpp”
  #include <memory>
  …

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

VC 6 で _UNICODE

VC 6 コンソール AP で,_UNICODE を付加してビルドすると
——————–構成: T_F_Stat – Win32 ReleaseU——————–
コンパイル中…
T_F_Stat.cpp
C:\…\VC98\INCLUDE\winnt.h(195) : error C2371: ‘LPTSTR’ : 再定義されています。異なる基本型です。
  C:\…\Develop\_.SRC\__CPR_\tstring.hxx(33) : ‘LPTSTR’ の宣言を確認してください。
C:\…\VC98\INCLUDE\winnt.h(196) : error C2371: ‘LPCTSTR’ : 再定義されています。異なる基本型です。
  C:\…\Develop\_.SRC\__CPR_\tstring.hxx(34) : ‘LPCTSTR’ の宣言を確認してください。
C:\…\Develop\_.SRC\__Mlt_\Get_Path.hxx(64) : error C2664: ‘GetCurrentDirectoryA’ :
  2 番目の引数を ‘unsigned short *’ から ‘char *’ に変換できません。 (新しい機能 ; ヘルプを参照)
  指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
C:\…\Develop\_.SRC\__Mlt_\Get_Path.hxx(91) : error C2664: ‘GetLongPathNameA’ :
  1 番目の引数を ‘const unsigned short *’ から ‘const char *’ に変換できません。 (新しい機能 ; ヘルプを参照)
  指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
C:\…\Develop\_.SRC\__Mlt_\Get_Path.hxx(114) : error C2664: ‘GetTempPathA’ :
  2 番目の引数を ‘unsigned short *’ から ‘char *’ に変換できません。 (新しい機能 ; ヘルプを参照)
  指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
C:\…\Develop\_.SRC\__Win\HelpWAPI.hxx(107) : error C2664: ‘GetModuleFileNameA’ :
  2 番目の引数を ‘unsigned short *’ から ‘char *’ に変換できません。 (新しい機能 ; ヘルプを参照)
  指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
C:\…\Develop\_.SRC\__Win\HelpWAPI.hxx(143) : error C2664: ‘GetComputerNameA’ :
  1 番目の引数を ‘unsigned short *’ から ‘char *’ に変換できません。 (新しい機能 ; ヘルプを参照)
  指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
C:\…\Develop\_.SRC\__Win\HelpWAPI.hxx(163) : error C2664: ‘GetUserNameA’ :
  1 番目の引数を ‘unsigned short *’ から ‘char *’ に変換できません。 (新しい機能 ; ヘルプを参照)
  指示された型は関連がありません; 変換には reinterpret_cast、 C スタイル キャストまたは関数スタイルのキャストが必要です。
cl.exe の実行エラー
T_F_Stat.exe – エラー 8、警告 0


tstring.h で LPxTSTR の定義は次の様にしていた.
#ifdef _MSC_VER
typedef TCHAR* LPTSTR ;
typedef const TCHAR* LPCTSTR ;
#else
typedef char* LPTSTR ;
typedef const char* LPCTSTR ;
#endif


対応方法がわからず,#include <Afx.h> を追加すると通る様にはなった.


_UNICODE だけでなく UNICODE も追加すると,Afx.h なしでも通る様になった.


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

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

fopen と sopen

_tfopen と _tsopen の mode の関係がわからなかったので,コードを抜粋
(VS8)\VC\crt\src\_open.c より
  /* First mode character must be ‘r’, ‘w’, or ‘a’. */
  switch (*mode) {
    case _T(‘r’):
      modeflag = _O_RDONLY;
      streamflag |= _IOREAD;
      break;
    case _T(‘w’):
      modeflag = _O_WRONLY | _O_CREAT | _O_TRUNC;
      streamflag |= _IOWRT;
      break;
    case _T(‘a’):
      modeflag = _O_WRONLY | _O_CREAT | _O_APPEND;
      streamflag |= _IOWRT;
      break;
    default:
      _VALIDATE_RETURN((“Invalid file open mode”,0), EINVAL, NULL);
    }


openfile.hxx
vchrfile.hxx

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

sh でエラー

sh を作成して実行すると,
  iwao@VB-Ubuntu:~/Documents$ sh mount_error.sh
  mount_error.sh: 1: mount_error.sh: sudo: not found
以前作成したものと比較したが,Ubuntu 上では見分けがつかなかった.
Windows 環境にコピーして,MIFES で開くとそれぞれで文字コードが異なる.
エラーになる sh をバイナリで開くと,EF BB BF が付加されていた.
どうも Ubuntu 上で利用したツールで,保存時に UTF-8 BOM 付としてしまったみたい.

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

ostrstream の利用でメモリリーク

次の様なコードでメモリリーク.freeze(false) がなかったのが原因.


tstring To_tstring (const double v,const int w=0,const int p=6,const long f=0) {
  tstring str ;
  std::ostrstream strBuf ;
  if (f != 0) {
    strBuf.flags(f) ;
    }
  {
    strBuf.width(w) ;
    strBuf.precision(p) ;
    }
  {
    strBuf << v ;
    strBuf << std::ends ;
    }
  {
    str = strBuf.str() ;
  // strBuf.rdbuf()->freeze(false) ;
    }
  return str ;
  }


Detected memory leaks!
Dumping objects ->
{385} normal block at 0x00038168, 512 bytes long.
Data: < 1.05 > 20 20 31 2E 30 35 00 CD CD CD CD CD CD CD CD CD
{363} normal block at 0x00037F20, 512 bytes long.
Data: <233.50 > 32 33 33 2E 35 30 00 CD CD CD CD CD CD CD CD CD
{339} normal block at 0x00037C70, 512 bytes long.
Data: < 967 > 20 20 20 39 36 37 00 CD CD CD CD CD CD CD CD CD
{315} normal block at 0x00037A28, 512 bytes long.
Data: < 875 > 20 20 20 38 37 35 00 CD CD CD CD CD CD CD CD CD
{291} normal block at 0x000377E0, 512 bytes long.
Data: < 997 > 20 20 20 39 39 37 00 CD CD CD CD CD CD CD CD CD
{269} normal block at 0x00037598, 512 bytes long.
Data: < 1.08 > 20 20 31 2E 30 38 00 CD CD CD CD CD CD CD CD CD
{245} normal block at 0x00037350, 512 bytes long.
Data: < 955 > 20 20 20 39 35 35 00 CD CD CD CD CD CD CD CD CD
{223} normal block at 0x00037108, 512 bytes long.
Data: < 1.15 > 20 20 31 2E 31 35 00 CD CD CD CD CD CD CD CD CD
{201} normal block at 0x00036EC0, 512 bytes long.
Data: < 1.02 > 20 20 31 2E 30 32 00 CD CD CD CD CD CD CD CD CD
{169} normal block at 0x000369B8, 512 bytes long.
Data: < 1.06 > 20 20 31 2E 30 36 00 CD CD CD CD CD CD CD CD CD
{143} normal block at 0x00036770, 512 bytes long.
Data: < 1003 > 20 20 31 30 30 33 00 CD CD CD CD CD CD CD CD CD
Object dump complete.
スレッド 0xDEC 終了、終了コード 0 (0x0)。
プログラム ‘C:\…\DmpFS\Debug\DmpFS.exe’ はコード 0 (0x0) で終了しました。


MSDN strstreambuf::freeze


2013/08/26
上のコードを Xcode でビルドすると,strBuf.flags(f) の所で
    /Volumes/…/t_string.hxx:47:10: No matching member function for call to ‘flags’
  利用する前に fmtflags 型にして利用する様に変更.
    std::ios_base::fmtflags f = std::ios_base::fmtflags(f_) ;


2013/08/28
_UNICODE に対応できなかったので,ostringstream を利用する様に変更.
  tstring To_tstring (const double v,const int w=0,const int p=6,const unsigned f_=std::ios::fixed) {
    tstring str ;
  #ifdef _UNICODE
    std::wostringstream strBuf ;
  #else
    std::ostringstream strBuf ;
  #endif
    std::ios_base::fmtflags f = std::ios_base::fmtflags(f_) ;
    if (f != 0) { strBuf.flags(f) ; }
    strBuf.width(w) ;
    strBuf.precision(p) ;
    strBuf << v ;
    str = strBuf.str() ;
    return str ;
    }

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