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 618931 - Error if gi18n-lib.h happens to come after config.h
Error if gi18n-lib.h happens to come after config.h
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 20:56 UTC by Christian Dywan
Modified: 2018-05-22 13:35 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christian Dywan 2010-05-17 20:56:37 UTC
I encounter an error if I use _() for localization. The problem depends on how Vala chooses to order #include lines in the generated C code. Apparently the order of "using" lines doesn't matter.

In file included from default/postler/postler-bureau.c:20:0:
/usr/include/glib-2.0/glib/gi18n-lib.h:29:2: Fehler: #error You must define GETTEXT_PACKAGE before including gi18n-lib.h. Did you forget to include config.h?

To elaborate, I define the symbol like this:

[CCode (cprefix = "", lower_case_prefix = "", cheader_filename = "config.h")]
namespace Config {
    [CCode (cname = "GETTEXT_PACKAGE")]
    public const string GETTEXT_PACKAGE;

My workaround to influence the #include order is right now this:

const string GETTEXT_PACKAGE_CONTENT = Config.GETTEXT_PACKAGE;

So the Vala compiler should actually ensure that the #includes are ordered correctly. In #vala the suggested solution was to introduce a 'crequire_symbol' so that Vala could know that it has to include config.h first.
Comment 1 Luca Bruno 2010-05-19 08:20:06 UTC
These have been the proposed solutions on IRC, rectify if I'm wrong:
1) a require_csymbol="GETTEXT_PACKAGE" on methods with cheader_filename="gi18n.h", then a Vala declaration is needed
2) an argument to specify what header to include before gi18n.h, i.e. CCode (cheader_filename="config.h,gi18n.h") or something like that, no Vala declaration needed
3) an argument CCode (before_include="gi18n.h") const string GETTEXT_PACKAGE, Vala declaration needed

Cons:
- 1 and 3 require Vala declaration, but usually keeps GETTEXT_PACKAGE or such in C headers.
- 1 needs the whole code to be traversed (only once of course) to find a symbol whose cname is require_csymbol
- 2 forces the final programmer to create a config.h, in autoconf one could even create a package-config.h instead
- 3 first gcc error, then the programmer as to guess or read FAQ on how to fix the problem

Pros:
- 1 makes valac generate a understandable error before getting to gcc
- 2 does not need a Vala declaration
- 3 faster than 1, no code traversing needed
Comment 2 GNOME Infrastructure Team 2018-05-22 13:35:32 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/98.