Re: [Vala] wrong struct code generated



On Tue, Aug 18, 2009 at 09:14:18 +0100, Spencer, Matthew wrote:
Firstly, there was a bug in my code, it should have been
  public unowned char SourceName[256];

You definitely don't want that. It creates a 256 bytes long structure. And
since char[256] is a value type, unowned does not make sense with it.

so sorry about that, but the problem still exists.  I also forgot to mention that I am using vala 0.7.5.

I initially tried without the [SimpleType], but this generates code:
void test_run_main (char** args, int args_length1) {
      TestInitParams _tmp0_ = {0};
      TestInitParams params;
      params = (memset (&_tmp0_, 0, sizeof (TestInitParams)), _tmp0_);
      params = params;
}

You didn't actually try not assiging it, did you?
Because the initialization (= {0}) it generates is all you need (but it
prints a warning).

To silence that warning, you can initialize yourself, because vala DOES
understand structure initializers, so:

TestInitParams _tmp_ = {{0}};
(while C happily accepts {0}, vala does not).

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



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