After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 618856 - Not possible to define a global pointer to a symbol
Not possible to define a global pointer to a symbol
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-17 09:29 UTC by pancake
Modified: 2018-05-22 13:35 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description pancake 2010-05-17 09:29:59 UTC
While this construction is valid in C, it isnt possible under Vala.

Here's a test program:

void main() {
        void * foo = &main; // shouldn't this be a valid expression in vala?
}

a.vala:2.13-2.13: error: syntax error, expected `;'
        const void * foo = &main;

When dropping the ampersand:

a.vala:2.9-2.18: error: Assignment: Cannot convert from `main' to `void*'
        void * foo = main;

So we force the casting as suggested:

    void *foo=(void*)main;

And it compiles. But moving the variable definition to the global context:

a.vala:1.1-1.10: error: Non-constant field initializers not supported in this context
void * foo = (void*)main;

So I add 'const', and that's what I get:

a.vala:1.1-1.31: error: `void*' not supported as type for constants
const void * foo = (void*)main;

and

[pancake@bitbox prg]$ valac a.vala
a.vala:1.27-1.30: error: syntax error, expected `)'
const void * foo = (const void*)main;
Comment 1 zarevucky.jiri 2010-07-19 23:22:14 UTC
There are two separate problems.
The first one is missing implicit typecast to void*. That may be a design decision, but I don't know for sure.
The second is that the function pointer is not considered a constant, while it should be. That should be fairly trivial to fix.
Comment 2 GNOME Infrastructure Team 2018-05-22 13:35:22 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/97.