error: expected primary-expression before ‘)’ to ken cast issue



Hello.  I'm trying to figure out why I get a compile error (in the subject of this message) for this cast during the initialization of a struct member variable.

in myclass.h

class MyClass {
    ...
    public:
        struct cpresets {
            char* soundfont_key;
            char* exists;
            UT_hash_handle hh;
        };
    ...
};
in myclass.cc

void myclass::mymethod() {
    ...
    struct cpresets *newpreset;
    newpreset = (cpresets*) malloc(sizeof( cpresets));
    ...

}
There is another place in the cc file where this works.

in myclass.cc

...
typedef struct {
    ...
}mystruct;

...

static instantiate(){
    ...
    //this line causes the compile error
    mystruct* me = (mystruct*) malloc(sizeof(mystruct));
    ...
}
I see the difference in the case where it works is that the struct is defined in the cc file and in the case where it doesnt work, the struct is a member vairable of the class header. Do you know why this is an issue or what I might be able to do to fix it?

Thanks.
Bill.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]