Bug 107608 - allow using gfile.h with glib
Summary: allow using gfile.h with glib
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-17 19:40 UTC by Christian Persch (GNOME)
Modified: 2018-08-21 10:46 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
proposed patch (843 bytes, text/plain)
2018-08-17 19:40 UTC, Christian Persch (GNOME)
Details

Description Christian Persch (GNOME) 2018-08-17 19:40:29 UTC
Created attachment 141172 [details]
proposed patch

(Moved to a separate bug as per bug 107599 comment 1.)

In bug 107599 I have a need to include goo/gfile.h in poppler/glib/poppler-document.cc together with <glib.h> However doing so leads to a compile error, since goo/gfile.h defines a "GDir" class which ufortunately is also the name of a glib type[https://gitlab.gnome.org/GNOME/glib/tree/master/glib/gdir.h]:

..../include/glib-2.0/glib/gdir.h:37:22: Fehler: conflicting declaration »typedef struct _GDir GDir«
 typedef struct _GDir GDir;
                      ^~~~
..../poppler/poppler/goo/gfile.h:199:7: Anmerkung: previous declaration as »class GDir«
 class GDir {
       ^~~~

[From bug 107599 comment 1]:
> I'm really not happy when we get workarounds in our code because 
> we collide with other repos type names, why should we be the ones
> adding workarounds and not the other codes?

I don't see a way to suppress glib's GDir. <glib.h> includes gdir.h and glib-autocleanups.h. The gdir.h file's contents is guarded by #ifndef __G_DIR_H__ which we could pre-define to skip its contents, but the <glib.h> also includes <glib-autocleanups.h> which requires gdir.h and has itself no such guard. Also these include guard names are not part of the glib API, they are internal and we cannot rely on them.

OTOH poppler controls its own names, so if we work around this inside poppler, we can rely on it.

The attached patch enables this by omitting the GDir (and GDirEntry) classes from goo/gfile.h when GFILE_NO_GDIR is #define'd.
Comment 1 GitLab Migration User 2018-08-21 10:46:51 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org'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.freedesktop.org/poppler/poppler/issues/370.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.