PDA

View Full Version : typedef question



MarkoSan
29th January 2008, 01:00
I've added this line of code into a header file:
//! new type declaration
typedef QMap<QString, QVariant> settingsType; and I get following errors:
mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/markofr/workspace/SettingsEditor'
c:\Qt\4.3.3\bin\uic.exe cmainwindow.ui -o ui_cmainwindow.h
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Qt\4.3.3\include\QtCore" -I"..\..\..\..\Qt\4.3.3\include\QtCore" -I"..\..\..\..\Qt\4.3.3\include\QtGui" -I"..\..\..\..\Qt\4.3.3\include\QtGui" -I"..\..\..\..\Qt\4.3.3\include" -I"c:\Qt\4.3.3\include\ActiveQt" -I"debug" -I"." -I"..\..\..\..\Qt\4.3.3\mkspecs\win32-g++" -o debug\CApplicationSettings.o CApplicationSettings.cpp
In file included from CApplicationSettings.h:11,
from CApplicationSettings.cpp:1:
setttingdefs.h:10: error: expected identifier before "typedef"
setttingdefs.h:10: error: expected init-declarator before "settingsType"
setttingdefs.h:10: error: expected `,' or `;' before "settingsType"
In file included from CApplicationSettings.cpp:1:
CApplicationSettings.h:28: error: `settingsType' does not name a type
mingw32-make[1]: *** [debug/CApplicationSettings.o] Error 1
mingw32-make[1]: Leaving directory `C:/Documents and Settings/markofr/workspace/SettingsEditor'
mingw32-make: *** [debug] Error 2

Why typedef is not working??!!

wysota
29th January 2008, 02:26
You have an error earlier in your code, probably a missing semicolon after a class declaration.

MarkoSan
29th January 2008, 02:41
Well the only errors are found in header file CApplicationSettings.h:
#ifndef CAPPLICATIONSETTINGS_H_
#define CAPPLICATIONSETTINGS_H_

// qt includes
#include <QSettings>
#include <QMap>
#include <QApplication>

// custom includes
#include "globals.h"
#include "setttingdefs.h"

/*!
* class responsible for whole EROSystem Settings
*/
class CApplicationSettings : public QSettings
{
Q_OBJECT

public:
CApplicationSettings(QObject *pParent);
~CApplicationSettings();
void addStringValue(QString strKey, QString strValue); // method for adding string value
void addIntValue(QString strKey, qint16 iValue); // method for adding integer value
void addFloatValue(QString strKey, qreal rValue); // method for adding real value

private:
settingsType m_KeyedValues;
};

#endif /*CAPPLICATIONSETTINGS_H_*/ in line 28 and then in file settingdefs.h:
#ifndef SETTTINGDEFS_H_
#define SETTTINGDEFS_H_

// qt includes
#include <QObject>
#include <QString>
#include <QMap>

//! new type declaration
typedef QMap<QString, QVariant> settingsType;

typedef struct structDBSettings
{
/*
QString strDBTypeValue(strdbType);
QString strDBHostValue(strdbHost);
QString strDBNameValue(strDatabaseName);
QString strDBUNameValue(strdbUserName);
QString strDBPassValue(strdbPassword);
*/
QString strDBTypeValue();
QString strDBHostValue();
QString strDBNameValue();
QString strDBUNameValue();
QString strDBPassValue();
}; // **** end of database key struct

/*!
* database settings keys
*/
//! database setttings main key
QString strDBSettingsKey("Database Settings/");
//! database type key
QString strDBTypeKey("Database Type");
//! database host key
QString strDBHostKey("Database Host");
//! database name key
QString strDBName("Database Name");
//! database access username key
QString strDBUName("Username");
//! database access password key
QString strDBPass("Password");
// **** end od database settings main key

#endif /*SETTTINGDEFS_H_*/ in line 10. And wysota, is this "design" of application settings class (i will reuse it in further projects, like my cdatabasefoundation class) ok or can you give me some useful hints?

ChristianEhrlicher
29th January 2008, 07:49
QVariant include is missing

MarkoSan
29th January 2008, 08:22
I've included it, same result, god damn, this must be some stupid mistake ...

ChristianEhrlicher
29th January 2008, 08:28
Ok, then something in global.h must be wrong