Re: C++ in kernel (was Re: exception in a device driver)

Raja R Harinath (harinath@cs.umn.edu)
16 Jan 1999 19:09:14 -0600


alan@lxorguk.ukuu.org.uk (Alan Cox) writes:
> > The rest is FUD: it's trivial to "figure out" when you are passing a
> > "self" pointer argument around: only non-static member functions have
> > them.
>
> On the contrary
>
>
> foo1.C
>
> blah->foofunc();
>
>
> foo2.C
>
> blahobject::foofunc()
> {
> printf("Hi");
> }
>
> a C++ compiler ends up passing "this" needlessly because it can't tell that
> foofunc of object blahobject need not know who it is.
>
> Thats only one example.

How is this different from its C equivalent:

foo1.c:

foofunc(&blah);

foo2.c:

void foofunc(blahobject *blah)
{
printf("Hi");
}

The C compiler shows the same lack of omniscience.

- Hari

-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/