typedef struct _cuobject cuObject;
//pointers to function
typedef int (*comparefunc)(const cuObject*, const cuObject*, int);
typedef struct _cutype{
comparefunc compare;
} cuType;
__host__ __device__ int object_compare(const cuObject* a, const
cuObject* b, int op){
return -1;
}
typedef struct _cuobject{
static cuType* type;
__host__ __device__ _cuobject(){
//type = NULL;
if(type == NULL){
cuType cuobjecttype = {
object_compare,
};
type = &cuobjecttype;
}
}
} cuObject;
int main(){
cuObject c;
}
I didn't put all the code but only the main part.
The error correspond to the line "if(type==NULL)":
test.cu(79): error: identifier "_ZN9_cuobject4typeE" is undefined
Seems that the compiler doesn't see the static pointer.
Filippo
On Tue, Mar 6, 2012 at 6:47 PM, Andreas Kloeckner
<[email protected]> wrote:
> <#part sign=pgpmime>
> On Tue, 6 Mar 2012 17:24:39 +0100, Sqoox85 <[email protected]> wrote:
>> Hi Andreas,
>>
>> So, is it possible to define static member data inside a struct in CUDA?
>> For example:
>> -------------------------------------------------------------------------------------------
>> typedef struct _cuobject{
>> static cuType* type;
>>
>> __host__ __device__ _cuobject(){
>> //type = NULL;
>> if(type == NULL){
>>
>> cuType cuobjecttype = {
>> cuObject_compare,
>> };
>> type = &cuobjecttype;
>> }
>> }
>> } cuObject;
>> -------------------------------------------------------------------------------------------
>>
>> If so, I could declare statically a cuobjecttype directly inside the struct
>> without thinking about allocate it in pycuda code, but
>> It give me an error. It say that in "if(type==NULL)" type is not
>> defined.
>
> Can you copy and paste a) a full code snippet and b) the complete error
> message?
>
> Andreas
>
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda