PDA

View Full Version : Error: Using Multiple files



3nc31
22nd November 2007, 06:49
Hi!!

I have these files and their headers:

1. main.cpp:
#include <QApplication>
#include "window.h"
#include "register.h"

2. window.h
#ifndef WINDOW_H
#define WINDOW_H
#include <QWidget>

3. window.cpp
#include <QtGui>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cstdlib>

#include "client.c"
#include "register.h"
#include "window.h"

4. register.h
#ifndef PRINCIPAL_H
#define PRINCIPAL_H

#include <QWidget>

5. register.cpp

#include <QtGui>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cstdlib>

#include "client.c"
#include "principal.h"
#include "window.h"

6. client.c

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <errno.h>

When I compile it, I get an error, the compiler complains that these
names are all duplicates. How can I get it to realize that these are
coming from the same header and refer to the same things instead of
making two different copies?

In register.cpp and window.cpp I need to use procedures of client.c

Thanks!!!!!

jpn
22nd November 2007, 10:23
Make a separate header file, client.h. You can't include a source file to other multiple source files.