Johnny [Life & Code]

Semper Exploro!

GCC : Assignment discards qualifiers from pointer target type

with 9 comments

GCC says "assignment discards qualifiers from pointer target type"

GCC complains :

foo.c: In function 'get_selected_item_label':
foo.c:264: warning: assignment discards qualifiers from pointer target type

Line 264 contains

text = gtk_label_get_text ( GTK_LABEL(widget));

Type for 'text' that i have defined is 'char *' but 'gtk_label_get_text' returns a "const ghcar*" .. so change the type of "text" to "const ghar *"


Well … i just want to share the errors/warning i get from GCC…

Written by Johnny

June 17, 2006 at 7:18 am

9 Responses

Subscribe to comments with RSS.

  1. This has to be you worst post yet!
    btw.. a typo… its gchar not ghcar :p (reminds me of GM cars …. bad joke 😦 )


    June 17, 2006 at 11:37 am

  2. Actually, I’ve been getting this warning all over the place and I had no clue how to fix it until now. Thanks!


    September 21, 2006 at 10:49 pm

  3. thanks .. encouraging

    Johnny Jacob

    September 23, 2006 at 3:10 am

  4. Since this page came up when I google’d the error, I decided to post this here:

    For those of you who receive this error when working with avr-gcc for the AVR microcontrollers, I’ve found two ways of fixing this problem:

    1) Cast the input:
    debounce(&PORTB, pin)
    debounce( (const uint8_t*) &PORTB, pin)

    Since that is tedious and ugly to do in every function call, I prefer the second way:

    2) Change the function prototype to handle voltiles:
    uint8_t debounce( uint8_t *port, uint8_t pin)
    uint8_t debounce( volatile uint8_t *port, uint8_t pin)

    Hope that helps!

    Chris Troutner

    Chris Troutner

    May 17, 2007 at 9:15 am

  5. Thanks Chris! I’m using an AVR micro and that did the trick.
    And Johnny thanks for the explanation.

    Michael Watchorn

    September 6, 2007 at 8:04 pm

  6. change it to

    const ghcar*=text = gtk_label_get_text ( GTK_LABEL(widget));

    might be it will resolve.

    Amaresh Ch Das

    May 14, 2008 at 2:09 pm

  7. thanks johnny jacob!

    maybe i’ve installed a borked release of the gtk library, but there seem to be several functions missing for GtkEntry.
    yet they are shown in the docs as being implemented…

    an important one is gtk_entry_buffer_get_length..

    without that, it could be a rigmarole malloc-ing the space for the buffer contents..

    where have those functions gone? Light fingered people at Gnome towers, no doubt.



    July 17, 2009 at 1:44 am

  8. Thank you very much!!

    Rakesh Ravindran

    October 4, 2009 at 6:03 pm

  9. Thanks. Your fix worked.

    My problem was very simple. I was declaring and initializing the variable EndValue in this line:
    double * EndValue = CurrentValue + SIZE;
    Where CurrentValue had already been declared as type ‘const double’, and SIZE was defined in an earlier #define statement. Because EndValue was a regular old double, and CurrentValue was a const double, I got errors.


    December 17, 2009 at 1:58 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: