[Click] Compile error using ELEMENT_PROVIDES

Xiaojun Feng fightfxj at gmail.com
Wed Mar 25 23:22:48 EDT 2009


I am using an open source click element and it works very well.

Now I want to add a new member variable to the elememt.

I define a new class in the file packetsrc.hh:

#ifndef PACKETSRC_HH
#define PACKETSRC_HH

CLICK_DECLS

class PacketSrc {        // line 6
    public:
        bool addPacket(char* data);

        PacketSrc();
        ~PacketSrc();

    private:
        char* packetdata;

};

CLICK_ENDDECLS  // line 18

#endif //PACKETSRC_H

and the implementation in packetsrc.cc:

#include "packetsrc.hh"

CLICK_DECLS

PacketSrc::PacketSrc() {}
PacketSrc::~PacketSrc() {}  // line 6

bool PacketSrc::addPacket(char* data)  // line 8
{
    return false;
}

CLICK_ENDDECLS  // line 13
ELEMENT_PROVIDES(PacketSrc)

Then I use make elemlist to update the element.conf.
But after 'make', there are several errors:

  CXX ../elements/local/packetsrc.cc
In file included from ../elements/local/packetsrc.cc:1:
../elements/local/packetsrc.hh:6: error: expected constructor, destructor,
or type conversion before ‘class’
../elements/local/packetsrc.hh:18: error: ‘CLICK_ENDDECLS’ does not name a
type
../elements/local/packetsrc.cc:6: error: expected constructor, destructor,
or type conversion before ‘::’ token
../elements/local/packetsrc.cc:8: error: ‘PacketSrc’ has not been declared
../elements/local/packetsrc.cc:8: warning: unused parameter ‘data’
../elements/local/packetsrc.cc:13: error: ‘CLICK_ENDDECLS’ does not name a
type
make[1]: *** [packetsrc.o] Error 1
make[1]: Leaving directory
`/media/work/fightfxj/thesis/linux_program/click-1.6.0/userlevel'
make: *** [userlevel] Error 2

How does the first error happen? Did I do anything wrong to define the class
PacketSrc?
I am just beginning to learn Click, maybe the question is kind of naive.

So every comment will be helpful to me.
Thanks very much!

-- 
Xiaojun Feng


More information about the click mailing list