io = {};
io.wchar = 111111;
debug((string)io.wchar); // (null)
So the problem here is that io.wchar
is still null
. You can look at the whole class here: https://github.com/stsdc/monitor/blob/dev/src/Managers/Process.vala
elementary OS Stack Exchange is a question and answer site for developers and users of elementary OS and applications. It only takes a minute to sign up.
Sign up to join this communityio = {};
io.wchar = 111111;
debug((string)io.wchar); // (null)
So the problem here is that io.wchar
is still null
. You can look at the whole class here: https://github.com/stsdc/monitor/blob/dev/src/Managers/Process.vala
I think the issue is you are using a cast, try using io.wchar.to_string() [https://valadoc.org/glib-2.0/uint64.to_string.html]
Edit: This worked for me based on your code, casting gave me a segfault.
struct Monitor.IO {
public uint64 wchar;
}
int main (string[] args) {
Monitor.IO io = {};
io.wchar = 111111;
warning (io.wchar.to_string ()); // Struct.vala:9: 111111
return 0;
}
0
. And also, please note, that I'm using this inside a class. Maybe there is something wrong with a declaration?
Two possible solutions:
IO? io { get; set; default = IO(); }
Note the question mark. (Solution by David Hewitt)IO io;
(Solution by thalexander)