0

To get myself started with Breakout I've been trying to create a simple program that, upon the click of a button, will change the color of a filled circle from black to yellow, and vice versa.

My logic is :

if button clicked and if color of circle is yellow
    set fill to black
if button clicked and if color of circle is black
    set fill to yellow

I've been trying to use the getColor function (provided in gobject.h) to discern the current color fill of the object and unfortunately at compile I receive an implicit declaration error, and a suggestion to use 'setColor' instead. I should mention that I have indeed 'included' gobjects.h in my program.

A snippet of how I'm trying to use the function:

        if ((strcmp(getColor(circle), #FFFFFF == 0)) && (strcmp(getActionCommand(lighty), "click") == 0))
    {
        setColor(circle, "YELLOW");
        printf("Light switched on!");
    }

The error which is returned :

myprogram.c:36:21: error: implicit declaration of function 'getColor' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if ((strcmp(getColor(circle), "#FFFFFF" == 0)) && (strcmp(getActionCommand(lighty), "click") == 0))
                ^

myprogram.c:36:21: note: did you mean 'setColor'?

/usr/include/spl/generic.h:353:6: note: 'setColor' declared here
void setColor(void *arg, string color);

I've searched through the documentation and header files, and it indicates that getColor should return a string containing # followed by 6 Hex digits containing the RGB of the color of the Gobject. Is this a bug, perhaps there's a better way to implement an extremely simple playaround like this with SPL?

Any help / comments are appreciated. Thanks.

1

It's a bug in the SPL library. getColor() doesn't actually work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .