undefined reference to function

Help pleaseeeeeeeeeeeeee !!
I have a problem , I can't figure out what's the error !!!
here my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#define HDR_ANT_PKT(p) ((struct hdr_ant_pkt*)hdr_ant_pkt::access(p))

struct hdr_ant_pkt {
	u_int8_t	pkt_type;

	// header access
	static int offset_;
	inline static int& offset() { return offset_; }
	inline static hdr_ant_pkt* access(const Packet* p) 
	{
		return (hdr_ant_pkt*) p->access(offset_);
	}

};


I've got this error
1
2
undefined reference to « hdr_ant_pkt::offset_ »
collect2: erreur: ld a retourné 1 code d'état d'exécution



please help me .
Thanks in advance
static member variables need to be instantiated.

Add this to a cpp file:

1
2
3
// Put this in ONE AND ONLY ONE cpp file:

int hdr_ant_pkt::offset_;
Yes , I already did that ,
1
2
3
4
5
6
7
8
9
10
11
int hdr_ant_pkt::offset_;
static class AntHeaderClass : public PacketHeaderClass {
	public:
		AntHeaderClass() : PacketHeaderClass("PacketHeader/Ant",
											sizeof(hdr_ant_pkt) +
											sizeof(struct hdr_scoutant_pkt) +
											sizeof(struct hdr_bkwant_pkt) +
											sizeof(struct hdr_maintenance_pkt)+
											sizeof(struct hdr_requete_pkt)+
											sizeof(struct hdr_data_pkt)) {
			bind_offset(&hdr_ant_pkt::offset_);
Last edited on
Topic archived. No new replies allowed.