Re: [Hexmap-user] Problems with test.c compile
Status: Beta
Brought to you by:
rsteinke
|
From: <rst...@w-...> - 2002-01-29 22:37:12
|
From: "Jeff Bulley" <cor...@ho...>
>
> Thanks for the quick response!
>
> I hope you can help me with a problem I've run into with test.c
> (CPPPFLAGS=glib gtk atk & pango includes)
>
> [jbulley@coreolyn hex_test]# g++ -g -Wall $CPPFLAGS test.c -o test
> test.c: In function `GtkWidget *setup_test_hex_display (HexWalker **)':
> test.c:116: initializer-string for array of chars is too long
> ..... (repeats for each string line)
> test.c:220: cannot convert `int' to `GConnectFlags' for argument `6' to
> `g_signal_connect_data (void *, const gchar *, void (*) (), void *,
> void (*) (void *, GClosure *), GConnectFlags)'
>
> I was able to eliminate the problem with 116 by removing one character from
> each string, however I have no clue what to do with line 220, and was
> wondering if there is an easy fix.
Instead of removing a character, change the first line in the declaration to
const gchar map[33][50] = {
which allows space for the terminating '\0'. Apparently gcc is more forgiving
of excess data than your compiler (I was even compiling with -Wall and it says
nothing), and since the code doesn't use the fact that the strings are null
terminated, it worked fine.
> Line 220:
>
> g_signal_connect_data(*walker, "moved", (GCallback) walker_moved,
> disp, NULL, 0);
Just do:
g_signal_connect_data(*walker, "moved", (GCallback) walker_moved,
disp, NULL, (GConnectFlags) 0);
It's just a cast from an int to an enum (which holds a set of bitflags).
> I'm more of a Java & Perl person than c/c++ but I can work most problems
> out, but I haven't worked with gtk+ till now. Of the gtk books out there
> are there any that stand out in your opinion?
Sounds like you're compiling this in C++ mode, which tends to be stricter
than C about typecasts. Let me know of any other warnings you get, I'll clean
them up.
Ron
|