ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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);
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
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?!!
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.