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 628756 - if main function is in a class called main bad C code generated
if main function is in a class called main bad C code generated
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator
0.9.x
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-09-04 08:52 UTC by Sam H
Modified: 2018-05-22 13:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Sam H 2010-09-04 08:52:19 UTC
If the main "function" is in a class called main bad C code generated.

Example:
/* example.gs - Begin example code */ 
class main
	def static main (args : array of string) : int
		return 0
/* example.gs - End example code */ 

Compilation:
$ valac example.gs -o example
example.vala.c:67: error: ‘main’ redeclared as different kind of symbol
example.vala.c:20: note: previous declaration of ‘main’ was here
example.vala.c:73: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
example.vala.c:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
example.vala.c: In function ‘value_main_collect_value’:
example.vala.c:113: error: ‘object’ undeclared (first use in this function)
example.vala.c:113: error: (Each undeclared identifier is reported only once
example.vala.c:113: error: for each function it appears in.)
example.vala.c: In function ‘value_main_lcopy_value’:
example.vala.c:129: error: ‘object_p’ undeclared (first use in this function)
example.vala.c: In function ‘value_set_main’:
example.vala.c:161: error: ‘old’ undeclared (first use in this function)
example.vala.c: In function ‘value_take_main’:
example.vala.c:179: error: ‘old’ undeclared (first use in this function)
example.vala.c: At top level:
example.vala.c:201: error: expected ‘)’ before ‘*’ token
example.vala.c:206: error: expected ‘)’ before ‘*’ token
example.vala.c: In function ‘main_get_type’:
example.vala.c:216: error: ‘main_instance_init’ undeclared (first use in this function)
example.vala.c: In function ‘main_ref’:
example.vala.c:227: error: ‘self’ undeclared (first use in this function)
example.vala.c: In function ‘main_unref’:
example.vala.c:235: error: ‘self’ undeclared (first use in this function)
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
Comment 1 pancake 2013-02-18 00:01:17 UTC
It's hard to make Vala detect all name collisions because it will fail if any C include file or any other static method/variable using the same name.

It is possible to control those issues at codegen-level. But only if the collision happens on Vala code. Vala should have a reserved blacklist for method/variable names. What do you devs think?
Comment 2 pancake 2013-02-18 00:02:23 UTC
Also, this issue can be reproduced on latest Vala 0.18.1 and also breaks on Vala (not only Genie). It's a codegen issue.
Comment 3 GNOME Infrastructure Team 2018-05-22 13:44:23 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/130.