I'm not inexperienced in C, but this one has me baffled. It involves GTK+3.0.
The relevant bits of code are:
Code:
char FlagEnt[NFLAGS][8] = ...
static GtkWidget * flentry[NFLAGS];
static GtkWidget * sflentry;
for (i = 0; i < NFLAGS; i++)
{
sflentry = GTK_WIDGET(gtk_builder_get_object(builder, FlagEnt[i]));
flentry[i] = sflentry;
}
Now this compiles OK, but doesn't behave as I expected.
Code:
(gdb) p sflentry
$2 = 0x555555aaea00
(gdb) p &sflentry
$4 = (GtkWidget **) 0x5555557bc1e0 <sflentry>
(gdb) p *sflentry
$5 = {parent_instance = {g_type_instance = {g_class = 0x5555558e80d0}, ref_count = 1, qdata = 0x555555aadfc0}, priv = 0x555555aae910}
(gdb) p flentry[7]
$6 = 0x0
(gdb) p &flentry[7]
$7 = (GtkWidget **) 0x5555557cdbd8 <flentry+56>
Where I was expecting flentry[7] to be the same as sflentry.
I've run a test program using int * to check my understanding of pointers in this context:
Code:
#include <stdio.h>
int * testc[3];
int main()
{
int * m;
int x = 10;
m = &x;
testc[0] = m;
printf("%p %p %d\n", m, testc[0], *testc[0]);
return 0;
}
And all seems fine.
What am I missing? Am I just being dense?
If anyone wants any more info, just let me know.