[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
strange error "changes meaning ..."
From: |
jk |
Subject: |
strange error "changes meaning ..." |
Date: |
Sat, 29 Jan 2005 17:11:45 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 |
Hello,
I am having es very strange error which I do not understand
threadform.h:44: error: declaration of `Consumer ThreadForm::Consumer'
thread.h:48: error: changes meaning of `Consumer' from `class Consumer'
t
It repeats for Producer ThreadForm::Producer ...
can anybody tell me the meaning of this error.
I am using Suse Linux 9.0 and gcc (g++) 3.3.1.
there are some Qt-generated files: threadform.cpp/h *.ui.h Makefile moc*.cpp
But perhaps the answer can be found without digging into Qt
tnx for a fast answer
Jörg
--
================= lat=52.35°N - lon=10.25°E ======================
http://www.ibk-consult.de
#include <qapplication.h>
#include "threadform.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
ThreadForm w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
/****************************************************************************
** ThreadForm meta object code from reading C++ file 'threadform.h'
**
** Created: Sat Jan 29 12:10:26 2005
** by: The Qt MOC ($Id: qt/moc_yacc.cpp 3.2.1 edited Aug 20 15:04 $)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#undef QT_NO_COMPAT
#include "threadform.h"
#include <qmetaobject.h>
#include <qapplication.h>
#include <private/qucomextra_p.h>
#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26)
#error "This file was generated using the moc from 3.2.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
const char *ThreadForm::className() const
{
return "ThreadForm";
}
QMetaObject *ThreadForm::metaObj = 0;
static QMetaObjectCleanUp cleanUp_ThreadForm( "ThreadForm",
&ThreadForm::staticMetaObject );
#ifndef QT_NO_TRANSLATION
QString ThreadForm::tr( const char *s, const char *c )
{
if ( qApp )
return qApp->translate( "ThreadForm", s, c, QApplication::DefaultCodec
);
else
return QString::fromLatin1( s );
}
#ifndef QT_NO_TRANSLATION_UTF8
QString ThreadForm::trUtf8( const char *s, const char *c )
{
if ( qApp )
return qApp->translate( "ThreadForm", s, c, QApplication::UnicodeUTF8 );
else
return QString::fromUtf8( s );
}
#endif // QT_NO_TRANSLATION_UTF8
#endif // QT_NO_TRANSLATION
QMetaObject* ThreadForm::staticMetaObject()
{
if ( metaObj )
return metaObj;
QMetaObject* parentObject = QDialog::staticMetaObject();
static const QUMethod slot_0 = {"languageChange", 0, 0 };
static const QUMethod slot_1 = {"startOrStopThreadB", 0, 0 };
static const QUMethod slot_2 = {"startOrStopThreadA", 0, 0 };
static const QMetaData slot_tbl[] = {
{ "languageChange()", &slot_0, QMetaData::Protected },
{ "startOrStopThreadB()", &slot_1, QMetaData::Private },
{ "startOrStopThreadA()", &slot_2, QMetaData::Private }
};
metaObj = QMetaObject::new_metaobject(
"ThreadForm", parentObject,
slot_tbl, 3,
0, 0,
#ifndef QT_NO_PROPERTIES
0, 0,
0, 0,
#endif // QT_NO_PROPERTIES
0, 0 );
cleanUp_ThreadForm.setMetaObject( metaObj );
return metaObj;
}
void* ThreadForm::qt_cast( const char* clname )
{
if ( !qstrcmp( clname, "ThreadForm" ) )
return this;
return QDialog::qt_cast( clname );
}
bool ThreadForm::qt_invoke( int _id, QUObject* _o )
{
switch ( _id - staticMetaObject()->slotOffset() ) {
case 0: languageChange(); break;
case 1: startOrStopThreadB(); break;
case 2: startOrStopThreadA(); break;
default:
return QDialog::qt_invoke( _id, _o );
}
return TRUE;
}
bool ThreadForm::qt_emit( int _id, QUObject* _o )
{
return QDialog::qt_emit(_id,_o);
}
#ifndef QT_NO_PROPERTIES
bool ThreadForm::qt_property( int id, int f, QVariant* v)
{
return QDialog::qt_property( id, f, v);
}
bool ThreadForm::qt_static_property( QObject* , int , int , QVariant* ){ return
FALSE; }
#endif // QT_NO_PROPERTIES
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <qstring.h>
#include <qmutex.h>
#include <qsemaphore.h>
#include "thread.h"
RoundBuffer::RoundBuffer()
{
DataSize = 100000 ;
BufferSize = 4096 ;
if( !flagBufferInitialized ){
buffer = ( char *)malloc( BufferSize ) ;
freespace = new QSemaphore( BufferSize ) ;
usedspace = new QSemaphore( BufferSize ) ;
}
}
RoundBuffer::~RoundBuffer()
{
}
void RoundBuffer::acquire( QSemaphore *semaphore )
{
*semaphore++ ;
}
void RoundBuffer::release( QSemaphore *semaphore )
{
*semaphore-- ;
}
Thread::Thread()
{
stopped = false;
}
Thread::~Thread()
{
}
void Thread::run()
{
for (;;) {
mutex.lock() ;
if (stopped) {
stopped = false ;
mutex.unlock() ; break ;
}
mutex.unlock();
cout << messageStr ;
fflush( NULL ) ;
sleep(1) ;
}
stopped = false ;
cout << endl ;
}
void Thread::stop()
{
#if 1 // 2 alternatives:
QMutexLocker locker( &mutex ) ;
stopped = true ;
#else
mutex.lock() ;
stopped = true ;
mutex.unlock() ;
#endif
}
void Thread::setMessage( const char *message ) {
messageStr.setAscii( message ) ;
}
Producer::Producer()
{
}
Producer::~Producer()
{
}
void Producer::run()
{
for( int ii = 0 ; ii < DataSize ; ++ii ) {
acquire( freespace ) ;
buffer[ ii % BufferSize ] = "ACGT"[ ( uint )rand() % 4 ] ;
release( usedspace ) ;
}
}
Consumer::Consumer()
{
}
Consumer::~Consumer()
{
}
void Consumer::run()
{
for( int ii = 0 ; ii < DataSize ; ++ii) {
acquire( usedspace ) ;
cerr << buffer[ ii % BufferSize ] ;
release( freespace ) ;
}
cerr << endl ;
}
#ifndef THREAD_H_INC
#define THREAD_H_INC
#include <qthread.h>
#include <qstring.h>
#include <qmutex.h>
#include <qsemaphore.h>
class RoundBuffer
{
protected:
static int DataSize ;
static int BufferSize ;
static bool flagBufferInitialized ;
public:
RoundBuffer() ;
~RoundBuffer() ;
static char *buffer ;
static QSemaphore *freespace ;
static QSemaphore *usedspace ;
void release( QSemaphore * ) ;
void acquire( QSemaphore * ) ;
} ;
class Thread : public QThread
{
public:
Thread() ;
~Thread() ;
void setMessage( const char *s ) ;
void run() ;
void stop() ;
private:
QMutex mutex ;
QString messageStr ;
volatile bool stopped ;
} ;
class Producer : public RoundBuffer, public Thread
{
public:
Producer() ;
~Producer() ;
void run() ;
} ;
class Consumer : public RoundBuffer, public Thread
{
public:
Consumer() ;
~Consumer() ;
void run() ;
} ;
#endif
/****************************************************************************
** Form implementation generated from reading ui file 'threadform.ui'
**
** Created: Sat Jan 29 16:38:39 2005
** by: The User Interface Compiler ($Id: qt/main.cpp 3.2.1 edited May
19 14:22 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "threadform.h"
#include <qvariant.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include "threadform.ui.h"
/*
* Constructs a ThreadForm as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
ThreadForm::ThreadForm( QWidget* parent, const char* name, bool modal, WFlags
fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "ThreadForm" );
setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0,
(QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth() ) );
setMaximumSize( QSize( 250, 100 ) );
setPaletteBackgroundColor( QColor( 255, 255, 127 ) );
QFont f( font() );
setFont( f );
ThreadFormLayout = new QVBoxLayout( this, 11, 6, "ThreadFormLayout");
QSpacerItem* spacer = new QSpacerItem( 20, 31, QSizePolicy::Minimum,
QSizePolicy::Expanding );
ThreadFormLayout->addItem( spacer );
layout1 = new QHBoxLayout( 0, 0, 6, "layout1");
threadAPushButton = new QPushButton( this, "threadAPushButton" );
layout1->addWidget( threadAPushButton );
threadBPushButton = new QPushButton( this, "threadBPushButton" );
layout1->addWidget( threadBPushButton );
quitPushButton = new QPushButton( this, "quitPushButton" );
layout1->addWidget( quitPushButton );
QSpacerItem* spacer_2 = new QSpacerItem( 16, 20, QSizePolicy::Expanding,
QSizePolicy::Minimum );
layout1->addItem( spacer_2 );
ThreadFormLayout->addLayout( layout1 );
languageChange();
resize( QSize(250, 80).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
// signals and slots connections
connect( threadAPushButton, SIGNAL( clicked() ), this, SLOT(
startOrStopThreadA() ) );
connect( threadBPushButton, SIGNAL( clicked() ), this, SLOT(
startOrStopThreadB() ) );
connect( quitPushButton, SIGNAL( clicked() ), this, SLOT( close() ) );
init();
}
/*
* Destroys the object and frees any allocated resources
*/
ThreadForm::~ThreadForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void ThreadForm::languageChange()
{
setCaption( tr( "Threads and Semaphore" ) );
threadAPushButton->setText( tr( "Start P" ) );
threadBPushButton->setText( tr( "Start C" ) );
quitPushButton->setText( tr( "&Quit" ) );
quitPushButton->setAccel( QKeySequence( tr( "Alt+Q" ) ) );
}
/****************************************************************************
** Form interface generated from reading ui file 'threadform.ui'
**
** Created: Sat Jan 29 17:03:40 2005
** by: The User Interface Compiler ($Id: qt/main.cpp 3.2.1 edited May
19 14:22 $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef THREADFORM_H
#define THREADFORM_H
#include <qvariant.h>
#include <qdialog.h>
#include "thread.h"
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QPushButton;
class ThreadForm : public QDialog
{
Q_OBJECT
public:
ThreadForm( QWidget* parent = 0, const char* name = 0, bool modal = FALSE,
WFlags fl = 0 );
~ThreadForm();
QPushButton* threadAPushButton;
QPushButton* threadBPushButton;
QPushButton* quitPushButton;
protected:
virtual void closeEvent( QCloseEvent * event );
QVBoxLayout* ThreadFormLayout;
QHBoxLayout* layout1;
protected slots:
virtual void languageChange();
private:
Consumer::Consumer Consumer;
Producer::Producer Producer;
void init();
private slots:
virtual void startOrStopThreadB();
virtual void startOrStopThreadA();
};
#endif // THREADFORM_H
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
**
** taken from Blanchette/Summerfield
*****************************************************************************/
#include <iostream>
#include <qstring.h>
#include "thread.h"
void ThreadForm::init()
{
}
void ThreadForm::startOrStopThreadB()
{
if( Consumer::Consumer.running() )
{
Consumer::Consumer.stop() ;
threadBPushButton->setText( tr( "Start C" ) ) ;
} else {
Consumer::Consumer.start() ;
threadBPushButton->setText( tr( "Stop C" ) ) ;
}
}
void ThreadForm::startOrStopThreadA()
{
if( Producer::Producer.running() )
{
Producer::Producer.stop() ;
threadAPushButton->setText(tr( "Start P" ) ) ;
} else {
Producer::Producer.start() ;
threadAPushButton->setText(tr( "Stop P" ) ) ;
}
}
void ThreadForm::closeEvent( QCloseEvent *event )
{
threadA.stop() ;
threadB.stop() ;
threadA.wait() ;
threadB.wait() ;
event->accept() ;
}
#############################################################################
# Makefile for building: semaphore
# Generated by qmake (1.06c) (Qt 3.2.1) on: Sat Jan 29 16:11:03 2005
# Project: semaphore.pro
# Template: app
# Command: $(QMAKE) "CONFIG+=thread" -o Makefile semaphore.pro
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
LEX = flex
YACC = yacc
CFLAGS = -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -fPIC
-DQT_THREAD_SUPPORT -Wall -W -g -D_REENTRANT -DQT_THREAD_SUPPORT -DQT_SHARED
-DQT_TABLET_SUPPORT -DQT_NO_DEBUG
CXXFLAGS = -pipe -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -fPIC
-DQT_THREAD_SUPPORT -Wall -W -g -D_REENTRANT -DQT_THREAD_SUPPORT -DQT_SHARED
-DQT_TABLET_SUPPORT -DQT_NO_DEBUG
LEXFLAGS =
YACCFLAGS= -d
INCPATH = -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/include
-I$(QTDIR)/include
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS) -L/usr/lib/ -L$(QTDIR)/lib/ -L/usr/X11R6/lib/ -lqt-mt
-lXext -lX11 -lm -lpthread
AR = ar cqs
RANLIB =
MOC = $(QTDIR)/bin/moc
UIC = $(QTDIR)/bin/uic
QMAKE = qmake
TAR = tar -cf
GZIP = gzip -9f
COPY = cp -f
COPY_FILE= $(COPY)
COPY_DIR = $(COPY) -r
DEL_FILE = rm -f
SYMLINK = ln -sf
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
####### Output directory
OBJECTS_DIR = ./
####### Files
HEADERS = thread.h
SOURCES = main.cpp \
thread.cpp
OBJECTS = main.o \
thread.o \
threadform.o
FORMS = threadform.ui
UICDECLS = threadform.h
UICIMPLS = threadform.cpp
SRCMOC = moc_threadform.cpp
OBJMOC = moc_threadform.o
DIST = semaphore.pro
QMAKE_TARGET = semaphore
DESTDIR =
TARGET = semaphore
first: all
####### Implicit rules
.SUFFIXES: .c .o .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
####### Build rules
all: Makefile $(TARGET)
$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) $(OBJCOMP)
mocables: $(SRCMOC)
uicables: $(UICDECLS) $(UICIMPLS)
$(MOC):
( cd $(QTDIR)/src/moc ; $(MAKE) )
Makefile: semaphore.pro /usr/lib/qt3/mkspecs/default/qmake.conf
/usr/lib/qt3/lib/libqt-mt.prl
$(QMAKE) "CONFIG+=thread" -o Makefile semaphore.pro
qmake:
@$(QMAKE) "CONFIG+=thread" -o Makefile semaphore.pro
dist:
@mkdir -p .tmp/semaphore && $(COPY_FILE) --parents $(SOURCES)
$(HEADERS) $(FORMS) $(DIST) .tmp/semaphore/ && $(COPY_FILE) --parents
threadform.ui.h .tmp/semaphore/ && ( cd `dirname .tmp/semaphore` && $(TAR)
semaphore.tar semaphore && $(GZIP) semaphore.tar ) && $(MOVE) `dirname
.tmp/semaphore`/semaphore.tar.gz . && $(DEL_FILE) -r .tmp/semaphore
mocclean:
-$(DEL_FILE) $(OBJMOC)
-$(DEL_FILE) $(SRCMOC)
uiclean:
-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)
yaccclean:
lexclean:
clean: mocclean uiclean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core
####### Sub-libraries
distclean: clean
-$(DEL_FILE) $(TARGET) $(TARGET)
FORCE:
####### Compile
main.o: main.cpp threadform.h \
thread.h
thread.o: thread.cpp thread.h
threadform.h: threadform.ui thread.h
$(UIC) threadform.ui -o threadform.h
threadform.cpp: threadform.h threadform.ui thread.h
$(UIC) threadform.ui -i threadform.h -o threadform.cpp
threadform.o: threadform.cpp threadform.ui.h \
threadform.h
moc_threadform.o: moc_threadform.cpp threadform.h thread.h
moc_threadform.cpp: $(MOC) threadform.h
$(MOC) threadform.h -o moc_threadform.cpp
####### Install
install: all
uninstall:
- strange error "changes meaning ...",
jk <=