[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] SoS: Undefined symbol _10hdr_simple.offset_ error



Since you are using a static variable you have to declare it as a global
somewhere in your c file. See a c++ reference. 

- Haobo

On Thu, 4 May 2000, Sudhindra Suresh Bengeri wrote:

> Date: Thu, 4 May 2000 13:21:40 -0400 (EDT)
> From: Sudhindra Suresh Bengeri <[email protected]>
> To: [email protected]
> Cc: [email protected]
> Subject: [ns] SoS: Undefined symbol _10hdr_simple.offset_ error
> 
> Hello Haobo,
> 
> I am getting a error linking error
> 
> Undefined                       first referenced
>  symbol                             in file
> _10hdr_simple.offset_               simpleagent.o
> 
> Here is how I have coded my SimpleAgent
> 
> <file: simpleagent.h>
> #define HDR_SIMPLE(p) (hdr_simple::access(p))
> 
> struct hdr_simple {
>   char ret;
>   static int offset_;
>   inline static hdr_simple * access(Packet *p) {
>       return (hdr_simple *) p->access(offset_);
>   };
> };
> 
> class SimpleAgent : public Agent {
> ...
> };
> 
> And in the file:simpleagent.cc
> 
> #include "simpleagent.h"
> ..
> 
> static class SimpleHeaderClass : public PacketHeaderClass {
> public:
>         SimpleHeaderClass() : PacketHeaderClass("PacketHeader/Simple",
>                                              sizeof(hdr_simple))
>         {
>              printf("SimpleHeader::Constructor\n");
>              bind_offset(&hdr_simple::offset_);
>         }
> } class_simplehdr;
> 
> 
> and in recv function I get try to get the access to my packetheader
> 
> struct hdr_simple *sh = HDR_SIMPLE(p);
> 
> 
> Please tell me what I could be doing wrong, I have a project submission
> due tomorrow. It was working fine when I had used 'off_simple_' defined in
> the SimpleAgent class, but I need to access the offset_ from other
> classes.
> 
> Thanks in anticipation.
> 
> Regards,
> Sudhin.
> 
> ****************** Sudhindra Suresh Bengeri *******************
> School:                       | Home:                         |
> Dept. of Computer Science     | 2502, Avent Ferry Rd          |
> NCSU, Raleigh, NC.            | Apt #206, Raleigh, NC - 27606 |
> Ph. 919 515 7135(TA room)     | Ph. 919 838 8746              |     
> my web projection: http://www4.ncsu.edu/~ssbenger
> 
>