I have a header file where i keep all my global variables without assigning a value and i include it in main code like this. I need to access a variable declared in Globals.h from Receiver.c, when i use any variable from Globals.h in Receiver.c, it Eclipse says Unknown Type Name
As per compiler, if i call Globals.h once, its in compiler memory right?
i dont include anything in Receiver.c
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "Globals.h"
#include "my_queue.h"
#include "Receiver.h"
#include "Receiver.c"
This is the contents of Globals.h
int stop_nw_global;
int datalen;
int cont[210];
struct in_addr localInterface;
struct sockaddr_in groupSock;
int sd;
char databuf[1024];
typedef struct UDP_Packet {
unsigned short Year; // year
unsigned char Month; // months
unsigned char Day; // day
unsigned char Hour; // hour
unsigned char Minute; // minute
unsigned char Seconds; // seconds
unsigned short Milliseconds; // milliseconds
unsigned char SeqNo; // packet sequence no
unsigned short CommandCode; // packet type
unsigned char DestSubSysID; // Destination sub system id (0 to 255)
unsigned char DestNodeID; // Destination node id
unsigned char SrcSubSysID; // Source sub system id
unsigned char SrcNodeID; // Source node id
unsigned short DataSize; // Data size in bytes
unsigned char AckSel; // select acknowledgment option
unsigned char AckID; // ID for ACK
unsigned char DataFlag; // Flag indicating single part(0) or multipart data (1)
unsigned char MessageID; // unique message ID
} UDP_Packet;
But when i try to add Globals.h in receive as well as main, it says, multiple definition of mostly all variable
src\udpexx1.o:/cygdrive/c/Eclipse Projects/udpexx1/Debug/C:\Eclipse Projects\udpexx1\SocketAPI/Globals.h:3: multiple definition of `stop_nw_global'; SocketAPI\Receiver.o:/cygdrive/c/Eclipse Projects/udpexx1/Debug/C:\Eclipse Projects\udpexx1\SocketAPI/Globals.h:3: first defined here
but both are pointing to Globals.h