Bug 97915 - g++ 5.4.0 cannot compile poppler (due to C++11 option)
Summary: g++ 5.4.0 cannot compile poppler (due to C++11 option)
Status: RESOLVED FIXED
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: 2016-09-24 17:17 UTC by Masamichi Hosoda
Modified: 2016-11-30 13:20 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
0001-Fix-g-C-11-option.patch (752 bytes, patch)
2016-09-24 17:20 UTC, Masamichi Hosoda
Details | Splinter Review
v2-0001-Fix-g-C-11-option.patch (927 bytes, patch)
2016-09-25 17:22 UTC, Masamichi Hosoda
Details | Splinter Review

Description Masamichi Hosoda 2016-09-24 17:17:18 UTC
I've found that current master branch (commit 183dbf3249e8db2398b63a749eb010bc0a89dc35) cannot be compiled by g++ 5.4.0.

```
  CXX      libgoo_la-gfile.lo
../../poppler/goo/gfile.cc: In function 'GBool openTempFile(GooString**, FILE**, const char*)':
../../poppler/goo/gfile.cc:408:37: error: 'mkstemp' was not declared in this scope
   fd = mkstemp((*name)->getCString());
                                     ^
../../poppler/goo/gfile.cc:416:39: error: 'fdopen' was not declared in this scope
   if (fd < 0 || !(*f = fdopen(fd, mode))) {
                                       ^
../../poppler/goo/gfile.cc: In function 'int Gfseek(FILE*, Goffset, int)':
../../poppler/goo/gfile.cc:557:34: error: 'fseeko' was not declared in this scope
   return fseeko(f, offset, whence);
                                  ^
../../poppler/goo/gfile.cc: In function 'Goffset Gftell(FILE*)':
../../poppler/goo/gfile.cc:571:18: error: 'ftello' was not declared in this scope
   return ftello(f);
                  ^
make[2]: *** [Makefile:584: libgoo_la-gfile.lo] Error 1
```
Comment 1 Masamichi Hosoda 2016-09-24 17:20:05 UTC
Created attachment 126763 [details] [review]
0001-Fix-g-C-11-option.patch

This patch uses `-std=gnu++11` since `-std=c++11` cannot use some feature.
Comment 2 Adrian Johnson 2016-09-25 04:23:30 UTC
I tried gcc 6.1.1 and it builds successfully.
Comment 3 Masamichi Hosoda 2016-09-25 10:28:18 UTC
I've tried some environments.
It seems that only Cygwin environment cannot compile.

Cygwin 64 bit + g++ 5.4.0:
  Failed.
  If the patch is applied, succeeded.

Ubuntu 14.04 LTS 64 bit + g++ 4.8.4:
  Succeeded.

Ubuntu 16.04 LTS 64 bit + g++ 5.4.0:
  Succeeded.

FreeBSD 10.1-RELEASE 64 bit + clang 3.4.1:
  Succeeded.

FreeBSD 10.1-RELEASE 64 bit * g++ 4.8.5:
  Succeeded.
Comment 4 Adrian Johnson 2016-09-25 12:07:19 UTC
I got gfile.cc to compile on cygwin by adding #define _BSD_SOURCE to the file. Although I read somewhere that _BSD_SOURCE has been replaced by _DEFAULT_SOURCE. We may need to add something to configure.ac and cmake to set the feature macro based on the compiler version.

The problem with using -std-gnu++11 is we don't want to allow gnu features that are incompatible with Visual C++.
Comment 5 Masamichi Hosoda 2016-09-25 13:37:21 UTC
(In reply to Adrian Johnson from comment #4)
> I got gfile.cc to compile on cygwin by adding #define _BSD_SOURCE to the
> file. Although I read somewhere that _BSD_SOURCE has been replaced by
> _DEFAULT_SOURCE. We may need to add something to configure.ac and cmake to
> set the feature macro based on the compiler version.
> 
> The problem with using -std-gnu++11 is we don't want to allow gnu features
> that are incompatible with Visual C++.

I've found the description of _BSD_SOURCE and _DEFAULT_VERSION.
http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

It says:

    To allow code that requires _BSD_SOURCE
    in glibc 2.19 and earlier and _DEFAULT_SOURCE in glibc 2.20 and
    later to compile without warnings, define both _BSD_SOURCE and
    _DEFAULT_SOURCE.
Comment 6 Masamichi Hosoda 2016-09-25 17:22:21 UTC
Created attachment 126777 [details] [review]
v2-0001-Fix-g-C-11-option.patch

This patch uses both _BSD_SOURCE and _DEFAULT_SOURCE instead of -std=gnu++11.
I've succeeded compile on Cygwin 64 bit environment with the patch.
Comment 7 Albert Astals Cid 2016-11-29 22:50:29 UTC
do you still need this patch with newer versions?
Comment 8 Masamichi Hosoda 2016-11-30 12:33:44 UTC
(In reply to Albert Astals Cid from comment #7)
> do you still need this patch with newer versions?

Current master branch can compiled on Cygwin 64 bit environment without the patch.
Thank you.


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.