This is our old Q&A Site. Please post any new questions and answers at

I need to work with a hash table keys of type struct (something similar to the defined struct below). These keys are related to number of parsed values from a UAT in my protocol dissector. I used g_hash_table_get_keys_as_array () but I'm getting several errors and warnings

: warning: old-style function definition [-Wold-style-definition]
   : warning: implicit declaration of function 'g_hash_table_get_keys_as_array' [-Wimplicit-function-declaration]
   : error: incompatible types when assigning to type 'struct key[]' from type 'int'
   : warning: variable 'keys_array' set but not used [-Wunused-but-set-variable]

I'm not sure why I'm getting these errors and not sure how to solve them. my guess that I'm not using the function in the proper way but again I'm not sure what I'm missing. I'd appreciate any hints that help me to better understand or solve the problem. my related code looks like the following:

typedef struct _key {
  guint32 num;
  address address;
  guint id;
} key;

static void 
    key  keys_array[] = NULL; 
    keys_array=  (*key ) g_hash_table_get_keys_as_array(my_key_hash);


Thank you. Flora

asked 13 Jan '15, 18:50

flora's gravatar image

accept rate: 100%

edited 13 Jan '15, 18:52

g_hash_table_get_keys_as_array is only available starting from GLib 2.40. Given the warnings you get, I guess you have an older GLib release. So you should look at alternative methods.

permanent link

answered 13 Jan '15, 23:13

Pascal%20Quantin's gravatar image

Pascal Quantin
accept rate: 30%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Jan '15, 18:50

question was seen: 862 times

last updated: 13 Jan '15, 23:13

p​o​w​e​r​e​d by O​S​Q​A