LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-29-2008, 03:30 AM   #1
muby
LQ Newbie
 
Registered: Oct 2007
Posts: 28

Rep: Reputation: 15
Exclamation error: multiple types in one declaration


Hi everyone

i'm compling my code with gcc-3.4 & i got the following error

Quote:
In file included from odmrp/defs.h:120,
from odmrp/jq_src_hash.h:43,
from odmrp/jq_src_hash.cc:37:
odmrp/hdr_o.h:140:8: warning: extra tokens at end of #endif directive
In file included from odmrp/jq_src_hash.cc:37:
odmrp/jq_src_hash.h:53: error: multiple types in one declaration
In file included from odmrp/jq_src_hash.cc:37:
odmrp/jq_src_hash.h:70:8: warning: extra tokens at end of #endif directive
make: *** [odmrp/jq_src_hash.o] Error 1
many suggested its a missing semicolon, but i dont see where im missing any in my following code
Quote:
#ifndef _jr_src_hash_h
#define _jr_src_hash_h

#include <odmrp/defs.h>

struct jr_src_hash_slot{
nsaddr_t src;
int seqno;
nsaddr_t prev_hop; /* why do we need this?? */
int hop_count;
struct jr_src_hash_slot *next;
};

typedef jr_src_hash_slot struct jr_src_hash_slot;

class JRSrcTable {
private:
struct jr_src_hash_slot *hash_table[OD_JR_SRC_HASH_SIZE];
public:
JRSrcTable();
~JRSrcTable();

int lookup(nsaddr_t src_addr, nsaddr_t prev_hop, int seqno);
int enterInTable(nsaddr_t src_addr, nsaddr_t prev_hop, int seqno);
int removeFromTable(nsaddr_t src_addr);

void printTable();
};

#endif _jr_src_hash_h
Thank you
 
Old 02-29-2008, 03:46 AM   #2
gatenet
LQ Newbie
 
Registered: Dec 2005
Posts: 1

Rep: Reputation: 0
What about this:

Code:
typedef jr_src_hash_slot struct jr_src_hash_slot;
Do you mean
Code:
typedef struct jr_src_hash_slot jr_src_hash_slot;
?
 
Old 02-29-2008, 04:23 AM   #3
muby
LQ Newbie
 
Registered: Oct 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks gatenet for your reply. I did use your suggestion but im still getting same error!!
 
Old 02-29-2008, 04:47 AM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Quote:
odmrp/hdr_o.h:140:8: warning: extra tokens at end of #endif directive
Code:
#endif _jr_src_hash_h
 
Old 02-29-2008, 05:11 AM   #5
muby
LQ Newbie
 
Registered: Oct 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks dmail for your reply, but multiple types in one declaration error is what really breaking the compilation, isn't it?!

i tried to google it, but no solution is working with me
 
Old 02-29-2008, 05:35 AM   #6
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Code:
 	Thanks dmail for your reply, but multiple types in one declaration error is what really breaking the compilation, isn't it?!

i tried to google it, but no solution is working with me
Sorry I thought you had sorted that out


Code:
#ifndef _jr_src_hash_h
#define _jr_src_hash_h

#include <odmrp/defs.h>

//forward declare the struct
struct jr_src_hash_slot;

struct jr_src_hash_slot{
nsaddr_t src;
int seqno;
nsaddr_t prev_hop; /* why do we need this?? */
int hop_count;
/*--struct--*/ jr_src_hash_slot *next;
};

/*--no need for this here its C++-- typedef jr_src_hash_slot struct jr_src_hash_slot;*/

class JRSrcTable {
private:
/*struct --no need for this here its C++*/ 
jr_src_hash_slot *hash_table[OD_JR_SRC_HASH_SIZE];
public:
JRSrcTable();
~JRSrcTable();

int lookup(nsaddr_t src_addr, nsaddr_t prev_hop, int seqno);
int enterInTable(nsaddr_t src_addr, nsaddr_t prev_hop, int seqno);
int removeFromTable(nsaddr_t src_addr);

void printTable();
};

#endif //_jr_src_hash_h
If that does not fix it post back, yet it should.

Last edited by dmail; 02-29-2008 at 05:43 AM.
 
Old 02-29-2008, 06:58 AM   #7
muby
LQ Newbie
 
Registered: Oct 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Unhappy

thanks dmail for your follow up, but when i tried your suggestion i got more errors as fellow
Quote:
In file included from odmrp/defs.h:120,
from odmrp/jq_src_hash.h:43,
from odmrp/jq_src_hash.cc:37:
odmrp/hdr_o.h:140:8: warning: extra tokens at end of #endif directive
odmrp/jq_src_hash.cc:42: error: syntax error before `::' token
odmrp/jq_src_hash.cc:45: error: ISO C++ forbids declaration of `index' with no
type
odmrp/jq_src_hash.cc:45: error: `int index' redeclared as different kind of
symbol
/usr/include/string.h:288: error: previous declaration of `char* index(const
char*, int)'
odmrp/jq_src_hash.cc:45: error: `src_addr' was not declared in this scope
odmrp/jq_src_hash.cc:48: error: syntax error before `if'
odmrp/jq_src_hash.cc:58: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:58: error: `hash_table' was not declared in this scope
odmrp/jq_src_hash.cc:59: error: syntax error before `while'
odmrp/jq_src_hash.cc:69: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:69: error: redefinition of `int temp'
odmrp/jq_src_hash.cc:58: error: `int temp' previously defined here
odmrp/jq_src_hash.cc:69: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:70: error: syntax error before `}' token
odmrp/jq_src_hash.cc:76: error: syntax error before `::' token
odmrp/jq_src_hash.cc:79: error: ISO C++ forbids declaration of `index' with no
type
odmrp/jq_src_hash.cc:79: error: redefinition of `int index'
odmrp/jq_src_hash.cc:45: error: `int index' previously defined here
odmrp/jq_src_hash.cc:79: error: `src_addr' was not declared in this scope
odmrp/jq_src_hash.cc:81: error: syntax error before `if'
odmrp/jq_src_hash.cc:85: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:85: error: redefinition of `int temp'
odmrp/jq_src_hash.cc:69: error: `int temp' previously defined here
odmrp/jq_src_hash.cc:85: error: `hash_table' was not declared in this scope
odmrp/jq_src_hash.cc:86: error: syntax error before `while'
odmrp/jq_src_hash.cc:91: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:91: error: redefinition of `int temp'
odmrp/jq_src_hash.cc:85: error: `int temp' previously defined here
odmrp/jq_src_hash.cc:91: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:92: error: syntax error before `}' token
odmrp/jq_src_hash.cc:100: error: syntax error before `::' token
odmrp/jq_src_hash.cc:103: error: ISO C++ forbids declaration of `index' with no
type
odmrp/jq_src_hash.cc:103: error: redefinition of `int index'
odmrp/jq_src_hash.cc:79: error: `int index' previously defined here
odmrp/jq_src_hash.cc:103: error: `src_addr' was not declared in this scope
odmrp/jq_src_hash.cc:105: error: syntax error before `if'
odmrp/jq_src_hash.cc:107: error: syntax error before `->' token
odmrp/jq_src_hash.cc:108: error: syntax error before `->' token
odmrp/jq_src_hash.cc:109: error: syntax error before `->' token
odmrp/jq_src_hash.cc:112: error: syntax error before `->' token
odmrp/jq_src_hash.cc:113: error: syntax error before `->' token
odmrp/jq_src_hash.cc:114: error: syntax error before `->' token
odmrp/jq_src_hash.cc:115: error: syntax error before `->' token
odmrp/jq_src_hash.cc:116: error: syntax error before `->' token
odmrp/jq_src_hash.cc:119: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:119: error: redefinition of `int temp'
odmrp/jq_src_hash.cc:91: error: `int temp' previously defined here
odmrp/jq_src_hash.cc:119: error: `hash_table' was not declared in this scope
odmrp/jq_src_hash.cc:121: error: syntax error before `if'
odmrp/jq_src_hash.cc:123: error: syntax error before `->' token
odmrp/jq_src_hash.cc:124: error: syntax error before `->' token
odmrp/jq_src_hash.cc:131: error: syntax error before `->' token
odmrp/jq_src_hash.cc:132: error: syntax error before `->' token
odmrp/jq_src_hash.cc:135: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:135: error: redefinition of `int temp'
odmrp/jq_src_hash.cc:119: error: `int temp' previously defined here
odmrp/jq_src_hash.cc:135: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:136: error: syntax error before `}' token
odmrp/jq_src_hash.cc:138: error: syntax error before `->' token
odmrp/jq_src_hash.cc:139: error: syntax error before `->' token
odmrp/jq_src_hash.cc:140: error: syntax error before `->' token
odmrp/jq_src_hash.cc:141: error: syntax error before `->' token
odmrp/jq_src_hash.cc:142: error: syntax error before `->' token
odmrp/jq_src_hash.cc:143: error: syntax error before `->' token
odmrp/jq_src_hash.cc:150: error: syntax error before `::' token
odmrp/jq_src_hash.cc:152: error: syntax error before `*' token
odmrp/jq_src_hash.cc:155: error: syntax error before `;' token
odmrp/jq_src_hash.cc:155: error: syntax error before `++' token
odmrp/jq_src_hash.cc:160: error: ISO C++ forbids declaration of `index' with no
type
odmrp/jq_src_hash.cc:160: error: redefinition of `int index'
odmrp/jq_src_hash.cc:103: error: `int index' previously defined here
odmrp/jq_src_hash.cc:160: error: `src_addr' was not declared in this scope
odmrp/jq_src_hash.cc:162: error: syntax error before `if'
odmrp/jq_src_hash.cc:167: error: ISO C++ forbids declaration of `hash_table'
with no type
odmrp/jq_src_hash.cc:167: error: variable-size type declared outside of any
function
odmrp/jq_src_hash.cc:167: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:168: error: syntax error before `delete'
odmrp/jq_src_hash.cc:181: error: syntax error before `->' token
odmrp/jq_src_hash.cc:192: error: syntax error before `::' token
odmrp/jq_src_hash.cc:195: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:195: error: `int fprintf' redeclared as different kind of
symbol
/usr/include/stdio.h:324: error: previous declaration of `int fprintf(FILE*,
const char*, ...)'
odmrp/jq_src_hash.cc:195: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:195: error: invalid conversion from `const char*' to `int'
odmrp/jq_src_hash.cc:197: error: syntax error before `for'
odmrp/jq_src_hash.cc:197: error: syntax error before `;' token
odmrp/jq_src_hash.cc:197: error: syntax error before `++' token
odmrp/jq_src_hash.cc:201: error: `i' was not declared in this scope
odmrp/jq_src_hash.cc:201: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:201: error: redefinition of `int fprintf'
odmrp/jq_src_hash.cc:195: error: `int fprintf' previously defined here
odmrp/jq_src_hash.cc:201: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:202: error: `i' was not declared in this scope
odmrp/jq_src_hash.cc:202: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:202: error: redefinition of `int fprintf'
odmrp/jq_src_hash.cc:201: error: `int fprintf' previously defined here
odmrp/jq_src_hash.cc:202: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:203: error: `i' was not declared in this scope
odmrp/jq_src_hash.cc:203: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:203: error: redefinition of `int fprintf'
odmrp/jq_src_hash.cc:202: error: `int fprintf' previously defined here
odmrp/jq_src_hash.cc:203: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:205: error: syntax error before `if'
odmrp/jq_src_hash.cc:207: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:207: error: redefinition of `int temp'
odmrp/jq_src_hash.cc:135: error: `int temp' previously defined here
odmrp/jq_src_hash.cc:207: error: `i' was not declared in this scope
odmrp/jq_src_hash.cc:209: error: syntax error before `while'
odmrp/jq_src_hash.cc:212: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:212: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:212: error: redefinition of `int fprintf'
odmrp/jq_src_hash.cc:203: error: `int fprintf' previously defined here
odmrp/jq_src_hash.cc:212: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:213: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:213: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:213: error: redefinition of `int fprintf'
odmrp/jq_src_hash.cc:212: error: `int fprintf' previously defined here
odmrp/jq_src_hash.cc:213: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:214: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:214: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:214: error: redefinition of `int fprintf'
odmrp/jq_src_hash.cc:213: error: `int fprintf' previously defined here
odmrp/jq_src_hash.cc:214: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:215: error: syntax error before `}' token
odmrp/jq_src_hash.cc:216: error: ISO C++ forbids declaration of `temp' with no
type
odmrp/jq_src_hash.cc:216: error: redefinition of `int temp'
odmrp/jq_src_hash.cc:207: error: `int temp' previously defined here
odmrp/jq_src_hash.cc:216: error: base operand of `->' is not a pointer
odmrp/jq_src_hash.cc:217: error: syntax error before `}' token
odmrp/jq_src_hash.cc:221: error: ISO C++ forbids declaration of `fprintf' with
no type
odmrp/jq_src_hash.cc:221: error: redefinition of `int fprintf'
odmrp/jq_src_hash.cc:214: error: `int fprintf' previously defined here
odmrp/jq_src_hash.cc:221: error: initializer list being treated as compound
expression
odmrp/jq_src_hash.cc:221: error: invalid conversion from `const char*' to `int'
odmrp/jq_src_hash.cc:222: error: syntax error before `}' token
odmrp/jq_src_hash.cc:225: error: syntax error before `::' token
odmrp/jq_src_hash.cc:228: error: syntax error before `;' token
odmrp/jq_src_hash.cc:228: error: syntax error before `++' token
odmrp/jq_src_hash.cc:230: error: `i' was not declared in this scope
odmrp/jq_src_hash.cc:230: error: syntax error before `->' token
odmrp/jq_src_hash.cc:231: error: `i' was not declared in this scope
odmrp/jq_src_hash.cc:231: error: syntax error before `->' token
odmrp/jq_src_hash.cc:232: error: `i' was not declared in this scope
odmrp/jq_src_hash.cc:232: error: syntax error before `->' token
odmrp/jq_src_hash.cc:238: error: syntax error before `::' token
make: *** [odmrp/jq_src_hash.o] Error 1
i solved similar problem in other files before by doing like this
Quote:
typedef struct jr_src_hash_slot jr_src_hash_slot
but not this time, i'm not sure where its coming from?!!

Last edited by muby; 02-29-2008 at 07:01 AM.
 
Old 02-29-2008, 07:08 AM   #8
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
The first error tells me that you have the same sort of problem that you had with this file
Quote:
odmrp/hdr_o.h:140:8: warning: extra tokens at end of #endif directive
And the other errors are in the source file, if you first fix the above error and still get more errors relating to the source file then please post that.
 
Old 02-03-2011, 05:13 PM   #9
jel220
LQ Newbie
 
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by muby View Post
Thanks dmail for your reply, but multiple types in one declaration error is what really breaking the compilation, isn't it?!

i tried to google it, but no solution is working with me
muby,

hello, Im trying to run ODMRP in NS2, and i have the same problem. Did you find any solution?????
 
  


Reply

Tags
ns2, odmrp



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
two types specified in one empty declaration cynthia_thomas Programming 4 04-16-2014 05:43 AM
Find command - multiple file types mrclisdue Linux - General 4 07-03-2006 03:48 AM
Configuring multipath to hds san results in multiple types of errors bret Linux - Software 1 05-12-2006 10:00 AM
Issues with multiple data types (C/C++) R00ts Programming 2 11-16-2005 08:37 PM
g++ compiler error declaration does not declare anything Basiltp Programming 4 10-11-2004 11:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration