[PD-dev] passing symbol arguments to a method

Ben Bogart - FMPM/F1999 bbogart at acs.ryerson.ca
Tue Jul 2 17:38:13 CEST 2002


Hello all,

I'm trying to build a PD method for this SDL function:

SDL_Surface *IMG_Load(const char *file);

problem is I can't figure out how to pass the symbol argument as a 
filename which IMG_Load expects. Here is my current method:

void load_images(mystruct *x, t_symbol* image1_src, t_symbol* image2_src)
{
        /* Symbol pointer stuff */

        image1 = IMG_Load( (char *) image1_src );
        if (image1_src == NULL) { post("Image 1 could not be opened"); }
        image2 = IMG_Load( (char *) image2_src );
        if (image2_src == NULL) { post("Image 2 could not be opened"); }
        SDL_Flip(screen);
}
Which results in a segfault. I tried it without typecasting but gcc just 
complains that its the wrong pointer type. 

        class_addmethod(myclass,                  
                        (t_method)load_images, 
                        gensym("open"), 
                        A_DEFSYM,
                        A_DEFSYM,
                        0);    

I also tried using argv and atom_getsymbol() with the same pointer-type 
porblem. 

What am I doing wrong?

Thanks
Ben

B. Bogart
---------





More information about the Pd-dev mailing list