Re: [Vala] valac 0.7.1 bug: Delegates are typedef'd before enums in generated C code.
- From: Yu Feng <rainwoodman gmail com>
- To: Jim Nelson <jim yorba org>
- Cc: Adam Dingle <adam yorba org>, vala-list gnome org, Andrew O'Mahony <andrew yorba org>
- Subject: Re: [Vala] valac 0.7.1 bug: Delegates are typedef'd before enums in generated C code.
- Date: Wed, 29 Apr 2009 23:43:34 -0400
Hi Jim,
Refer to http://bugzilla.gnome.org/show_bug.cgi?id=578191
Yu
On Mon, 2009-04-27 at 15:14 -0700, Jim Nelson wrote:
I've entered a bug in the database
(http://bugzilla.gnome.org/show_bug.cgi?id=580513) but am posting here
because this problem blocks me from transitioning to Vala 0.7, which I
would like to do.
In my code, a delegate returns an enum. In valac's generated C code,
the delegate is typedef'd before the enum, which the compiler
obviously doesn't like.
There's a twist to all of this. It will only compile under 0.6.1 if
the enum is in a different file as the delegate declaration (because
the enum is declared in a separate, guarded .h file). Even separating
the two, this code will not compile in 0.7.1.
If anyone can suggest a workaround until this is fixed, it would be
greatly appreciated.
Here's the vala code:
enum TestEnum {
foo,
bar,
xyzzy,
}
delegate void tdelegate(TestEnum te);
void main() {
}
which 0.7.1 transforms into this C code:
#include <glib.h>
#include <glib-object.h>
#define TYPE_TEST_ENUM (test_enum_get_type ())
// *** Next line generates error: "error: expected β)β before βteβ"
typedef void (*tdelegate) (TestEnum te, void* user_data);
typedef enum {
TEST_ENUM_foo,
TEST_ENUM_bar,
TEST_ENUM_xyzzy
} TestEnum;
GType test_enum_get_type (void);
void _main (void);
GType test_enum_get_type (void) {
static GType test_enum_type_id = 0;
if (G_UNLIKELY (test_enum_type_id == 0)) {
static const GEnumValue values[] = {{TEST_ENUM_foo,
"TEST_ENUM_foo", "foo"}, {TEST_ENUM_bar, "TEST_ENUM_bar", "bar"},
{TEST_ENUM_xyzzy, "TEST_ENUM_xyzzy", "xyzzy"}, {0, NULL, NULL}};
test_enum_type_id = g_enum_register_static ("TestEnum",
values);
}
return test_enum_type_id;
}
void _main (void) {
}
int main (int argc, char ** argv) {
g_type_init ();
_main ();
return 0;
}
Thanks,
-- Jim Nelson
Yorba
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]