[aspectc-user] non-inline introduction
Daniel Lohmann
daniel.lohmann at informatik.uni-erlangen.de
Wed Mar 26 11:18:53 CET 2008
On 26.03.2008, at 10:54, Panu Bloigu wrote:
> Hi,
>
> arnd-hendrik.mathias at nefkom.net wrote:
>> Hi,
>> Zitat von Panu Bloigu <panu.bloigu at gmail.com>:
>>> Hello.
>>>
>>> arnd-hendrik.mathias at nefkom.net wrote:
>>>> So, I cannot add a slice of a static member to a virtual class,
>>>> at all?
>>>
>>> I can't see any reason that would prevent you from doing this.
>> So, is it still virtual if there's an implementation for a virtual
>> ctor?
>
> C++ does not recognize such a thing as 'virtual class' (a virtual
> base class, OTOH, is entirely different thing). A class can be
> *abstract* if it contains at least one pure virtual method. If a
> class is abstract, an instance of the class can not be created,
> regardless whether there is an constructor explicitly defined or not
> (in fact, C++ compiler creates a default ctor in any case). So
> adding a definition of an empty ctor to a class that has no
> explicitly defined ctor, changes nothing. But by doing this you can
> create a translation unit for the class.
>
> A constructor can not be virtual -- it does not make sense.
Arnd-Hendrik,
All that is required is *some* member definition in a
corresponding .cpp file to serve as a link between declaration and
definition translation unit for the weaver. If there absolutely is no
member for which it makes sense to be defined in a .cpp file (as in
case of an interface), I'd recommend to define a dummy symbol for this
purpose:
// Device.h
class Device {
private:
// never accessed, will be removed by symbol-level linking
static int acc_link_dummy;
public:
...
};
// Device.cpp
Device::acc_link_dummy = 4711;
I think (but haven't tested) that you can even embrace all this with
an #ifdef __puma #endif. The __puma preprocessor symbol is defined
during weaving, it can be used to let the weaver see different code
than the compiler:
// Device.h
class Device {
#ifdef __puma
// never seen by the compiler, only the weaver sees this
static int acc_link_dummy;
#endif
public:
...
};
// Device.cpp
#ifdef __puma
Device::acc_link_dummy = 4711;
#endif
Daniel
More information about the aspectc-user
mailing list