Re: [Vala] valac 0.7.1 bug: Delegates are typedef'd before enums in generated C code.

Hi Jim,

Refer to


On Mon, 2009-04-27 at 15:14 -0700, Jim Nelson wrote:
I've entered a bug in the database
( 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 {

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  {
} 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",
    return test_enum_type_id;

void _main (void) {

int main (int argc, char ** argv) {
    g_type_init ();
    _main ();
    return 0;


-- Jim Nelson

Vala-list mailing list
Vala-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]