0

ログファイルを生成するコードがあります:-

// INI.cpp: implementation of the CINI class.


//#include "stdafx.h"

#include "INI.h"
#include <iostream>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


CINI::CINI(char* szFileName)
{

    memset(m_szFileName, 0x00, 255); 
    memcpy(m_szFileName, szFileName, strlen(szFileName));

}

CINI::~CINI()
{

}


float CINI::ReadFloat(char* szSection, char* szKey, float fltDefaultValue)
{
    char szResult[255]; 
    char szDefault[255]; 
    float fltResult; sprintf(szDefault, "%f",fltDefaultValue); 
    GetPrivateProfileString(szSection,  szKey, szDefault, szResult, 255, m_szFileName);  
    fltResult =  atof(szResult); return fltResult;
}

bool CINI::ReadBoolean(char* szSection, char* szKey, bool bolDefaultValue)
{
    char szResult[255]; 
    char szDefault[255]; 
    bool bolResult; 
    sprintf(szDefault, "%s", bolDefaultValue? "True" : "False"); 
    GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName);
    bolResult =  (strcmp(szResult, "True") == 0 || strcmp(szResult, "true") == 0) ? true : false; return bolResult;
}

char* CINI::ReadString(char* szSection, char* szKey, const char* szDefaultValue)
{ 
    memset(m_szResult, 0x00, 255); 
    GetPrivateProfileString(szSection,  szKey, szDefaultValue, m_szResult, 255, m_szFileName);  
    return m_szResult;
}

void CINI::WriteInteger(char* szSection, char* szKey, int iValue)
{ 
    char szValue[255]; sprintf(szValue, "%d", iValue); 
    WritePrivateProfileString(szSection,  szKey, szValue, m_szFileName);
}

void CINI::WriteFloat(char* szSection, char* szKey, float fltValue)
{
    char szValue[255]; 
    sprintf(szValue, "%f", fltValue); 
    WritePrivateProfileString(szSection,  szKey, szValue, m_szFileName);
}

void CINI::WriteBoolean(char* szSection, char* szKey, bool bolValue)
{ 
    char szValue[255]; sprintf(szValue, "%s", bolValue ? "True" : "False"); 
    WritePrivateProfileString(szSection,  szKey, szValue, m_szFileName);
}

void CINI::WriteString(char* szSection, char* szKey, char* szValue)
{
    WritePrivateProfileString(szSection,  szKey, szValue, m_szFileName);
}

コードを実行すると、次のエラーが表示されます:-

c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): 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]

StdAfx.h と StdAfx.cpp を含めると、次のエラーが発生します。

 StdAfx.cpp
1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): 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]
1>  INI.cpp
1>c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): 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]

私は VS2010 を使用しており、win32 コンソール プロジェクトをビルドする必要があります。助けてください。

4

1 に答える 1

1

プロジェクトのプロパティを変更する必要があります。

[プロジェクト] -> [プロパティ] (最後のメニュー項目) -> [構成プロパティ] -> [全般] に移動します。

「MFC の使用」オプションを含む「プロジェクトの既定値」セクションが表示されます。「静的ライブラリで MFC を使用する」を選択します。

基本的に、コード生成設定でマルチスレッドの静的ランタイム ライブラリが選択され、使用しようとしている MFC ライブラリが dll ベースの C ランタイムを使用して構築されているため、競合が発生しています。

于 2012-05-22T08:46:59.000 に答える