Dakons blog

Erstellt: 23. 4. 2007, 13:56
Geändert: 23. 4. 2007, 16:05

Bug des Tages: "not pointer-to-object type"

Tags:

Das ganze in Englisch, damit man auf google auch vernünftige Hinweise findet für die Fehlermeldung. Den Bug habe ich übrigens selbst gebaut, nur der Vollständigkeit halber.

My g++ told me "error: ‘void*’ is not a pointer-to-object type". Google spit out only things about ancient versions of gcc, but nothing that lead me to the solution. Now that I know what it means it's rather obvious, but nevertheless. Here is some example code:

class b {
public:
    void *vp;
};

int d(b *cp)
{
    return cp->vp->i;	// error
}

If I had done it in C it would also been wrong:

typedef struct {
    void *vp;
} b;

int d(b *cp)
{
    return cp->vp->i;	// error
}

But now the error is (at least to me) much clearer: "dereferencing ‘void *’ pointer". Sometimes it's useful to have a boss :)

Anbieterkennzeichnung