Solved

multiple defination error in QT programme

Posted on 2004-04-16
10
449 Views
Last Modified: 2007-12-19
hi
i'm trying to write a simple client for my chat server. the client is a qt programme. on giving the make command, it gives the following output:

kapil@linux:~/ProjectStuff/XChatClient> make
g++  -o XChatClient main.o moc_ClientWindow.o moc_ConnectDialog.o moc_XChatClient.o  -L/usr/lib/ -L/usr/lib/qt3/lib/ -L/usr/X11R6/lib/ -lqt -lXext -lX11 -lm
moc_ClientWindow.o(.text+0x0): In function `ClientWindow::ClientWindow[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ClientWindow::ClientWindow[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x0): first defined here
moc_ClientWindow.o(.text+0x6d0): In function `ClientWindow::ClientWindow[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ClientWindow::ClientWindow[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x6d0): first defined here
moc_ClientWindow.o(.text+0xda0): In function `ClientWindow::Start()':
: multiple definition of `ClientWindow::Start()'
main.o(.text+0xda0): first defined here
moc_ClientWindow.o(.text+0xdf0): In function `ClientWindow::ProbeCtrlPort()':
: multiple definition of `ClientWindow::ProbeCtrlPort()'
main.o(.text+0xdf0): first defined here
moc_ClientWindow.o(.text+0xf70): In function `ClientWindow::ProbeDataPort()':
: multiple definition of `ClientWindow::ProbeDataPort()'
main.o(.text+0xf70): first defined here
moc_ClientWindow.o(.text+0x1180): In function `ClientWindow::SendMsg()':
: multiple definition of `ClientWindow::SendMsg()'
main.o(.text+0x1180): first defined here
moc_ClientWindow.o(.text+0x15b0): In function `ClientWindow::DoLogout()':
: multiple definition of `ClientWindow::DoLogout()'
main.o(.text+0x15b0): first defined here
moc_ClientWindow.o(.text+0x1690): In function `ClientWindow::LockUnlockSendPushButton()':
: multiple definition of `ClientWindow::LockUnlockSendPushButton()'
main.o(.text+0x1690): first defined here
moc_ConnectDialog.o(.text+0x0): In function `ConnectDialog::ConnectDialog[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ConnectDialog::ConnectDialog[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x1750): first defined here
moc_ConnectDialog.o(.text+0x680): In function `ConnectDialog::ConnectDialog[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ConnectDialog::ConnectDialog[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x1dd0): first defined here
moc_ConnectDialog.o(.text+0xd00): In function `ConnectDialog::Dial()':
: multiple definition of `ConnectDialog::Dial()'
main.o(.text+0x2450): first defined here
moc_ConnectDialog.o(.text+0x10c0): In function `ConnectDialog::Quit()':
: multiple definition of `ConnectDialog::Quit()'
main.o(.text+0x2810): first defined here
moc_XChatClient.o(.text+0x0): In function `ClientWindow::ClientWindow[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ClientWindow::ClientWindow[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x0): first defined here
moc_XChatClient.o(.text+0x6d0): In function `ClientWindow::ClientWindow[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ClientWindow::ClientWindow[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x6d0): first defined here
moc_XChatClient.o(.text+0xda0): In function `ClientWindow::Start()':
: multiple definition of `ClientWindow::Start()'
main.o(.text+0xda0): first defined here
moc_XChatClient.o(.text+0xdf0): In function `ClientWindow::ProbeCtrlPort()':
: multiple definition of `ClientWindow::ProbeCtrlPort()'
main.o(.text+0xdf0): first defined here
moc_XChatClient.o(.text+0xf70): In function `ClientWindow::ProbeDataPort()':
: multiple definition of `ClientWindow::ProbeDataPort()'
main.o(.text+0xf70): first defined here
moc_XChatClient.o(.text+0x1180): In function `ClientWindow::SendMsg()':
: multiple definition of `ClientWindow::SendMsg()'
main.o(.text+0x1180): first defined here
moc_XChatClient.o(.text+0x15b0): In function `ClientWindow::DoLogout()':
: multiple definition of `ClientWindow::DoLogout()'
main.o(.text+0x15b0): first defined here
moc_XChatClient.o(.text+0x1690): In function `ClientWindow::LockUnlockSendPushButton()':
: multiple definition of `ClientWindow::LockUnlockSendPushButton()'
main.o(.text+0x1690): first defined here
moc_XChatClient.o(.text+0x1750): In function `ConnectDialog::ConnectDialog[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ConnectDialog::ConnectDialog[not-in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x1750): first defined here
moc_XChatClient.o(.text+0x1dd0): In function `ConnectDialog::ConnectDialog[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)':
: multiple definition of `ConnectDialog::ConnectDialog[in-charge](QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)'
main.o(.text+0x1dd0): first defined here
moc_XChatClient.o(.text+0x2450): In function `ConnectDialog::Dial()':
: multiple definition of `ConnectDialog::Dial()'
main.o(.text+0x2450): first defined here
moc_XChatClient.o(.text+0x2810): In function `ConnectDialog::Quit()':
: multiple definition of `ConnectDialog::Quit()'
main.o(.text+0x2810): first defined here
moc_XChatClient.o(.text+0x2850): In function `XChatClient::XChatClient[not-in-charge]()':
: multiple definition of `XChatClient::XChatClient[not-in-charge]()'
main.o(.text+0x2850): first defined here
moc_XChatClient.o(.text+0x2970): In function `XChatClient::XChatClient[in-charge]()':
: multiple definition of `XChatClient::XChatClient[in-charge]()'
main.o(.text+0x2970): first defined here
moc_XChatClient.o(.text+0x2a90): In function `XChatClient::init(int, char**)':
: multiple definition of `XChatClient::init(int, char**)'
main.o(.text+0x2a90): first defined here
moc_XChatClient.o(.text+0x2bf0): In function `XChatClient::DoShutDown()':
: multiple definition of `XChatClient::DoShutDown()'
main.o(.text+0x2bf0): first defined here
collect2: ld returned 1 exit status
make: *** [XChatClient] Error 1
kapil@linux:~/ProjectStuff/XChatClient>

what is wrong?
i have included some .h files  at more than one place. but if i remove those inclusions, and include only in one place in the main programme, then make different errors, that of undefined references etc..

please help as i dont know anything about how qt compiles and this is my 1st attempt at qt.
neither do i know what make actually does...

Regards!
0
Comment
Question by:logicTRANCE
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10839962
Hi logicTRANCE,

Protect multiple inclusion of header files using #ifndefs

#ifndef THIS_HEADER_FILE
#define THIS_HEADER_FILE
//entire contents of the header file
#endif

you will have a different string for THIS_HEADER_FILE for each header file you have
and do NOT declare a function/class/struct in more than one places

Sunnycoder
0
 
LVL 12

Assisted Solution

by:stefan73
stefan73 earned 50 total points
ID: 10840176
Hi logicTRANCE,
Looks like you have duplicate symbols.
Check if you implemented any of your methods in a header file. Start with the first offending symbol:

ClientWindow::ClientWindow(QWidget*, char const*, QSocketDevice*, QSocketDevice*, QString*)

This should be defined in a source file (.cpp, .C, .cxx, etc.), not in a header file.

Cheers,
Stefan
0
 
LVL 1

Author Comment

by:logicTRANCE
ID: 10844813
i tried both but neither worked. so now i'm posting my code..maybe i'm doing something very wrong...please help

main.cpp----------------------

#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>

#ifndef XCHATCLIENT_H
      #include "XChatClient.h"
#endif

int main(int argc, char **argv)
{
      XChatClient Client;
      return (Client.init(argc, argv));
}

XChatClient.h------------------

#define XCHATCLIENT_H

#ifndef CLIENTWINDOW_H
      #include "ClientWindow.h"
#endif
#ifndef CONNECTDIALOG_H
      #include "ConnectDialog.h"
#endif

#include<qapplication.h>
#include<qlineedit.h>
#include<qtextedit.h>
#include<qlistbox.h>
#include<qdialog.h>
#include<qlabel.h>
#include<qpushbutton.h>
#include<qfont.h>
#include<qsocketdevice.h>
#include<qobject.h>

class XChatClient : QObject
{
      Q_OBJECT

      private:
                  QSocketDevice CtrlSockDevice, DataSockDevice;
                  ClientWindow *ClientWin;
                  ConnectDialog *ConnectDiag;
                  QString *NickNameString;
      public:
                  XChatClient();
                  int init(int argc, char **argv);
      public slots:
                  void DoShutDown();
};


ConnectDialog.h-----------------

#define CONNECTDIALOG_H

#include <sys/socket.h>

#include<qapplication.h>
#include<qlabel.h>
#include<qlineedit.h>
#include<qpushbutton.h>
#include<qfont.h>
#include<qsocketdevice.h>
#include<qwidget.h>

class ConnectDialog : public QWidget
{
      Q_OBJECT

      public:
                  ConnectDialog(QWidget *parent = 0, const char *name = 0, QSocketDevice *CSock=0, QSocketDevice *DSock=0, QString *NickName=0);
      public slots:
                  void Dial();
                  void Quit();
      signals:
                  void CtrlConnEstablished();
                  void ShutDown();
                  
      
      private:
                  QString *NNString;
                  QLabel *NNLabel, *ServerIPLabel;
                  QLineEdit *NNEdit, *ServerIPEdit;
                  QPushButton *ConnectPushButton, *CancelPushButton;
                  QSocketDevice *CtrlSockDevice;
                  QSocketDevice *DataSockDevice;
};

ClientWindow.h-------------------

#define CLIENTWINDOW_H

#include<netinet/in.h>

#include<qapplication.h>
#include<qlineedit.h>
#include<qtextedit.h>
#include<qlistbox.h>
#include<qlabel.h>
#include<qdialog.h>
#include<qpushbutton.h>
#include<qsocketdevice.h>
#include<qwidget.h>

union MsgLen
{
      char bytes[2];
      short int value;
};

class ClientWindow : public QWidget
{
      Q_OBJECT
      
      private:
                  QDialog *MainWindow;
                  QTextEdit *MsgViewer;
                  QPushButton *LogoutPushButton, *SendPushButton;
                  QLabel *OULabel;
                  QListBox *OUL;
                  QLineEdit *MsgLineEdit;

                  QSocketDevice *CtrlSockDev, *DataSockDev;
                  QString *NN;

                  char SendBuffer[1000];
                  char RecvBuffer[3003];

      public:
                  ClientWindow(QWidget *parent=0, const char *name=0, QSocketDevice *CtrlSockDevice=0, QSocketDevice *DataSockDevice=0, QString *Nickname=0);

                  void ProbeCtrlPort();      //probes the control port for control messeges and takes appropriate action
                  void ProbeDataPort();      //probes data port for incoming data messeges and takes necessary action

      public slots:
                  void Start();
                  void SendMsg();
                  void DoLogout();
                  void LockUnlockSendPushButton();

      signals:
                  void LogoutComplete();
};

XChatClient.cpp-----------------

#include "XChatClient.h"

XChatClient::XChatClient()
{
      QObject::connect(ConnectDiag, SIGNAL(CtrlConnEstablished()), ClientWin, SLOT(Start()));
      QObject::connect(ConnectDiag, SIGNAL(ShutDown()), this, SLOT(DoShutDown()));
      QObject::connect(ClientWin, SIGNAL(LogoutComplete()), this, SLOT(DoShutDown()));
}

int XChatClient::init(int argc, char **argv)
{
      QApplication ClientApp(argc, argv);
      
      NickNameString = new QString("Guest");
      ConnectDiag = new ConnectDialog(0, "ConnectDiag", &CtrlSockDevice, &DataSockDevice, NickNameString);
      ClientWin = new ClientWindow(0, "ClientWin", &CtrlSockDevice, &DataSockDevice, NickNameString);
      ConnectDiag->show();
      
      return(ClientApp.exec());
}


void XChatClient::DoShutDown()
{
      ConnectDiag->close();
      ClientWin->close();
      
      qApp->quit();
}

ConnectDialog.cpp--------------

#include "ConnectDialog.h"

ConnectDialog::ConnectDialog(QWidget *parent, const char *name, QSocketDevice *CSock, QSocketDevice *DSock, QString *NickName) : QWidget(parent, name)
{
      CtrlSockDevice = CSock;
      DataSockDevice = DSock;
      NNString = NickName;
      
      this->setMinimumSize(300,210);      //no resize allowed
      this->setMaximumSize(300,210);
      
      NNLabel = new QLabel("Please enter your nickname (maximum 20 characters):", this, "NNLabel");
      NNEdit = new QLineEdit(this, "NNEdit");
      
      ServerIPLabel = new QLabel("Server IP address:", this, "ServerIPLabel");
      ServerIPEdit = new QLineEdit(this, "ServerIPEdit");
      
      ConnectPushButton = new QPushButton("Connect", this, "ConnectPushButton");
      CancelPushButton = new QPushButton("Cancel", this, "CancelPushButton");
      
      NNLabel->setGeometry(50,20,300,40);
      NNLabel->setFont(QFont("Arial",10,QFont::Bold));
      
      NNEdit->setGeometry(50,65,300,85);
      
      ServerIPLabel->setGeometry(50,100,150,120);
      ServerIPLabel->setFont(QFont("Arial",10,QFont::Bold));
      
      ServerIPEdit->setGeometry(50,135,300,155);
      
      ConnectPushButton->setGeometry(50,170,130,190);
      CancelPushButton->setGeometry(170,170,250,190);
      
      connect(ConnectPushButton, SIGNAL(clicked()), this, SLOT(Dial()));
      connect(CancelPushButton, SIGNAL(clicked()), this, SLOT(Quit()));
}

void ConnectDialog::Dial()
{
      QString ServerIPString = ServerIPEdit->text();
      QHostAddress ServerIPAddress;                              //this will contain server ip extracted from ServerIPEdit widget
      
      *NNString = NNEdit->text();
      *NNString = NNString->stripWhiteSpace();
                  
      if(NNString->length() < 1 || NNString->length() > 20)      return;
      
      if(ServerIPAddress.setAddress(ServerIPString) == FALSE)      return;
            
      int CtrlSock = socket(AF_INET, SOCK_STREAM, 0);      //create sockets
      int DataSock = socket(AF_INET, SOCK_STREAM, 0);
      
      CtrlSockDevice->setSocket(CtrlSock, QSocketDevice::Stream);
      DataSockDevice->setSocket(DataSock, QSocketDevice::Stream);
      
      CtrlSockDevice->setBlocking(FALSE);
      DataSockDevice->setBlocking(FALSE);
      
      if(CtrlSockDevice->connect(ServerIPAddress, Q_UINT16(19471)) == FALSE)
      {
            close(CtrlSock);
            close(DataSock);
            return;
      }
      else
      {
            char SendNNCString[22] = "1";
            strcat(SendNNCString, NNString->ascii());
            
            if(strlen(SendNNCString) < 20)
            {
                  strcat(SendNNCString,"#");
            }
            SendNNCString[21] = '\0';
            
            CtrlSockDevice->writeBlock(SendNNCString,strlen(SendNNCString));
            
            DataSockDevice->connect(ServerIPAddress, Q_UINT16(19511));
            
            this->hide();
            emit CtrlConnEstablished();
      }
}

void ConnectDialog::Quit()
{
      this->hide();
      emit ShutDown();
}

ClientWindow.cpp------------------

#include "ClientWindow.h"

ClientWindow::ClientWindow(QWidget *parent, const char *name, QSocketDevice *CtrlSockDevice, QSocketDevice *DataSockDevice, QString *Nickname) : QWidget(parent,name)
{
      this->CtrlSockDev = CtrlSockDevice;
      this->DataSockDev = DataSockDevice;
      this->NN = Nickname;

      strcpy(SendBuffer,"");
      strcpy(RecvBuffer,"");

      MainWindow = new QDialog(this, "MainWindow");
      MainWindow->setGeometry(0,0,800,600);

      MsgViewer = new QTextEdit(MainWindow, "MsgViewer");
      MsgViewer->setGeometry(20,20,620,520);
      MsgViewer->setReadOnly(TRUE);
      MsgViewer->setFont(QFont("Arial"));

      LogoutPushButton = new QPushButton("Logout", MainWindow, "LogoutPushButton");
      LogoutPushButton->setGeometry(680,20,740,50);
      LogoutPushButton->setFont(QFont("Arial", 15, QFont::Bold));

      OUL = new QListBox(MainWindow,"OUL");
      OUL->setGeometry(640,80,780,520);
      OUL->clear();

      MsgLineEdit = new QLineEdit(MainWindow, "MsgLineEdit");
      MsgLineEdit->setGeometry(20,540,620,560);
      MsgLineEdit->setFont(QFont("Arial"));

      SendPushButton = new QPushButton("Send!", MainWindow, "SendPushButton");
      SendPushButton->setGeometry(690,540,730,560);
      SendPushButton->setFont(QFont("Arial", 15, QFont::Bold));

      QObject::connect(SendPushButton, SIGNAL(clicked()), this, SLOT(SendMsg()));
      QObject::connect(LogoutPushButton, SIGNAL(clicked()), this, SLOT(DoLogout()));
      QObject::connect(MsgLineEdit, SIGNAL(returnPressed()), this, SLOT(SendMsg()));
      QObject::connect(MsgLineEdit, SIGNAL(textChanged()), this, SLOT(LockUnlockSendPushButton()));
}

void ClientWindow::Start()
{
      MainWindow->show();      //show the main client window
      while(1)
      {
            ProbeCtrlPort();
            ProbeDataPort();
      }
}

void ClientWindow::ProbeCtrlPort()
{
      if(CtrlSockDev->bytesAvailable() > 0)
      {
            strcpy(RecvBuffer,"");
            CtrlSockDev->readBlock(RecvBuffer,sizeof(RecvBuffer));
            if(RecvBuffer[0] == '3')      //we got an OUL update!!
            {
                  OUL->clear();
                  
                  short int numofnicks = short(RecvBuffer[2]);
                  
                  char TempNickName[21]="";
                  int i=0;
                  for(; i<numofnicks; i++)
                  {
                        strncpy(TempNickName, (RecvBuffer+(i*20)+2), 20);
                        TempNickName[20] = '\0';
                        int j=0;
                        for(; j<20; j++)
                        {
                              if(TempNickName[j] == '#')      break;
                        }
                        TempNickName[j] = '\0';
                        
                        OUL->insertItem(QString(TempNickName));
                  }
            }
            else      strcpy(RecvBuffer,"");
      }
}

void ClientWindow::ProbeDataPort()
{
      if(DataSockDev->bytesAvailable() > 0)
      {
            strcpy(RecvBuffer,"");
            DataSockDev->readBlock(RecvBuffer,sizeof(RecvBuffer));
            
            char sourceNN[21]="";//, destinNN[21]="";
            //char MsgType;
            union MsgLen MLen;
            char Msg[3000]="";

            strncpy(sourceNN, RecvBuffer, 20);
            sourceNN[20] = '\0';
            int j=0;
            for(; j<20; j++)
            {
                  if(sourceNN[j] == '#')      break;
            }
            sourceNN[j] = '\0';

            /*strncpy(destinNN, RecvBuffer+20, 20);
            destinNN[20] = '\0';
            for(; j<20; j++)
            {
                  if(destinNN[j] == '#')      break;
            }
            destinNN[j] = '\0';

            MsgType = RecvBuffer[40];*/
            MLen.bytes[0] = RecvBuffer[41];
            MLen.bytes[1] = RecvBuffer[42];
            MLen.value = ntohs(MLen.value);

            strncpy(Msg, RecvBuffer+43, MLen.value);
            Msg[MLen.value]='\0';
            
            QString DisplayMsg(sourceNN);
            DisplayMsg += ': ';
            DisplayMsg += Msg;
            
            MsgViewer->append(DisplayMsg);
            MsgViewer->scrollToBottom();
            
            strcpy(RecvBuffer,"");
      }
}

void ClientWindow::SendMsg()
{
      if((MsgLineEdit->text()).length() <= 0)      return;
      else
      {
            char SourceNN[21]="";
            strcpy(SourceNN, NN->ascii());
            int len = NN->length();
            
            SourceNN[len] = '\0';
                  
            if(len < 20)
            {
                  int i=len;
                  for(; i<20; i++)
                  {
                        SourceNN[i] = '#';
                  }
            }
            SourceNN[20] = '\0';
            
            char DestinNN[21]="";
            QListBoxItem *DestNN = OUL->selectedItem();
            QString DestNNstr = DestNN->text();
            strcpy(DestinNN, DestNNstr.ascii());
            
            len = DestNNstr.length();
            DestinNN[len] = '\0';
            if(len < 20)
            {
                  int i=len;
                  for(; i<20; i++)
                  {
                        DestinNN[i] = '#';
                  }
            }
            DestinNN[20] = '\0';
            
            QString Msg = MsgLineEdit->text();
                        
            union MsgLen MLen;
            MLen.value = htons(Msg.length());


Regards!
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10846485
The last method (ClientWindow::SendMsg()) is not complete.
0
 
LVL 1

Author Comment

by:logicTRANCE
ID: 10849643
err...thanks but that was because the post got too long!
;-)

i did what stefan73 told and also added
#ifndef CONNECTDIALOG_H
  #include "ConnectDialog.h"
#endif
#ifndef CLIENTWINDOW_H
  #include "ClientWindow.h"
#endif

to main()
and it compiled fine....but now is gives segmentation fault!!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10849670
Compile your program with the -g compiler switch and run it under gdb:
gdb your_program
(gdb) run parm1 parm2 parm3
... crash ...
(gdb) where

Replace parm1 parm2 parm3 with the parameters you would use to start your program on the command line. Look at the output of the where command, it will tell you where it crashed. You can also use the bt command to look at the stack.
0
 
LVL 1

Author Comment

by:logicTRANCE
ID: 10849833
how to compile with -g? i give qmake and make commands and -g is for gcc..so how do i go about it? any parameters to make?
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 100 total points
ID: 10850518
Are you running "make" after qmake? If so, just set the CXXFLAGS environment variable:

export CXXFLAGS=-g

Then run qmake/make and it should add the -g parameter to the command line whenever g++ is called. You If you also have C files, you need to set CFLAGS as well (exaclty the same way).
0
 
LVL 45

Assisted Solution

by:sunnycoder
sunnycoder earned 50 total points
ID: 10859722
1. you seem to confuse sunnycoder and stefan73

2. I had not recommended this

========================================================
ClientWindow.h-------------------

#define CLIENTWINDOW_H          <<<<<<<<<<<< no protection here

#include<netinet/in.h>
blah blah
===========================================================

or
===========================================================
XChatClient.h------------------

#define XCHATCLIENT_H

#ifndef CLIENTWINDOW_H
     #include "ClientWindow.h"
#endif
#ifndef CONNECTDIALOG_H
     #include "ConnectDialog.h"
#endif
blah blah
============================================================

It should rather have been something like this

XChatClient.h------------------
#ifndef XCHATCLIENT_H
#define XCHATCLIENT_H
     #include "ClientWindow.h"
     #include "ConnectDialog.h"
     blah blah ... rest of the entire file
#endif

once XChatClient has been included, XCHATCLIENT_H will be defined and cannot be included again ... this way you have lesser chances of error as compared to the first method
0
 
LVL 1

Author Comment

by:logicTRANCE
ID: 10869180
hi sunnycoder!
well sorry about the mix up...what i meant was that i seperated the class declarations and definations as stefan73 told, and used a header file protection...but diferent than what you told....

this is what you recommended in your last post...

#ifndef XCHATCLIENT_H
#define XCHATCLIENT_H
     #include "ClientWindow.h"
     #include "ConnectDialog.h"
     blah blah ... rest of the entire file
#endif

well that surely seems to be more elegant...thanks!

i got clear of the errors i was getting, by using recommendations by all 3 of you (khkremer too)..
but now there is some problem with clientwindow widget not being drawn to the screen properly...but that'll be another post...i'm closing this one now...i'll split points btn all 3 of you...since only after using recommendations from all 3 of you did i get out of the errors!

Regards!
-logicTRANCE
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
low latency kernel configuration 3 170
Linux script help 27 237
Identify Linux loader 67 164
BASH script to modify crontab? 3 23
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now