类定义文件中存在Win32程序编译器错误

Win32 program compiler errors in class definition file

本文关键字:程序 编译器 错误 Win32 存在 定义 文件      更新时间:2023-10-16

我正在尝试用Visual C++进行编译,并刚刚将此配置文件加载器/解析器添加到我的项目中。对于类CProfileData中定义的某些函数,它至少接收到两个错误中的一个:

missing type specifier - int assumed.
syntax error : missing ',' before '&'

显然,这应该只是一个引用字符串

#ifdef UVSS_EXPORTS
#define UVSS_API __declspec(dllexport)
#else
#define UVSS_API __declspec(dllimport)
#endif

class CProfileData
{
public:
    UVSS_API CProfileData(){};
    UVSS_API CProfileData(const string& profileFile);
    UVSS_API ~CProfileData(void);
    UVSS_API bool GetVariable( const string& sectionName, const string& variableName, string& valueRet );
    UVSS_API bool GetSection( const string& sectionName, SECTION_MAP **pMapRet );
    UVSS_API bool GetVariableW( const string& sectionName, const string& variableName, wstring& valueRet );
    UVSS_API bool GetVariableInt( const string& sectionName, const string& variableName, int *pIntRet );
private:
    void ToLower( string& str );
    void TrimWhitespace( string& str);   
    bool IsComment( const string& str );
    bool IsSection( const string& str, string& secName );
    bool IsVariable( const string& str, string& name, string& value );
    PROFILE_MAP         m_mapProfile;
};

包括<string>:

#include <string>

在你写过string的地方写std::string

文件中执行以下任一操作都不是一个好主意:

using namespace std; //avoid doing this
using std::string;   //avoid doing this as well

确保在包含以下标题之前出现这两行:

#include <string>
using std::string;
相关文章: