Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:55:53+00:00 2026-05-31T03:55:53+00:00

I’m into a problem that I can’t really understand. I want to include directly

  • 0

I’m into a problem that I can’t really understand.
I want to “include” directly into my C code a series of icons. Using the tool gdk-pixbuf-csource (with –struct option) I produced a file that initializes a ‘const’ pixdata structure for each image.
And example of an encoded image is this:

const GdkPixdata pixdata_flipH = {
   0x47646b50, /* Pixbuf magic: 'GdkP' */
   24 + 479, /* header length + pixel_data length */
   0x2010002, /* pixdata_type */
   64, /* rowstride */
   16, /* width */
   16, /* height */
   /* pixel_data: */
   "\257\0\0\0\0\1\0\0\0\1\203\0\0\0\0\2\0\0\0\2\40J\207E\202\40J\207\377"
   "\202\0\0\0\0\202\40J\207\377\2\40J\207E\40J\207\2\202\0\0\0\0\1\0\0\0"
   "\2\203\0\0\0\0\4\40J\2072\40J\207\377\276\322\352\377\40J\207\377\202"
   <data continues......>
   "\0\0\0\0\1\40J\207\1\204\0\0\0\0\1\40J\207\3\227\0\0\0\0\1\0\0\0\3\244"
};

I want to include the icons in some buttons, so I prepared the following series of statements:

GtkWidget *icon_flipH = gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_flipH, FALSE, NULL));
GtkWidget *icon_flipV = gtk_image_new_from_pixbuf(gdk_pixbuf_from_pixdata(&pixdata_flipV, FALSE, NULL)); 
// and so on...

In this way I’ll add the image to the button with the function:

gtk_button_set_image(GTK_BUTTON(button_flipH), icon_flipH);

Well… The GCC compiler goes in error saying that “initializer element is not constant” at each line containing gdk_pixbuf_from_pixdata() function. I can’t figure out why, because the function needs a const structure pointer and actually my structures are declared ‘const’.

Am I forgetting something? Is it not the right way to include images into the code and create pixbufs? Any tutorial in this case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:55:54+00:00Added an answer on May 31, 2026 at 3:55 am

    Objects defined at file scope (like icon_flipH) have static storage duration: their lifetime is the lifetime of the program and they are initialized before the startup of the program. You can only initialize objects with static storage duration with a constant expression (e.g., 0, 10 + 32, or sizeof (int)). The result of a function call is not a constant expression.

    // File scope
    
    GtkWidget *icon_flipH = NULL;   // OK, NULL is a constant expression  
    GtkWidget *icon_flipV = foo();  // Not OK, foo is not a constant expression
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.