This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH v2 1/7] common: add scoped_fd
- From: "Metzger, Markus T" <markus dot t dot metzger at intel dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Tue, 13 Feb 2018 17:28:26 +0000
- Subject: RE: [PATCH v2 1/7] common: add scoped_fd
- Authentication-results: sourceware.org; auth=none
- Dlp-product: dlpe-windows
- Dlp-reaction: no-action
- Dlp-version: 11.0.0.116
- References: <1516976072-19282-1-git-send-email-markus.t.metzger@intel.com> <1516976072-19282-2-git-send-email-markus.t.metzger@intel.com> <CAH=s-PMr4qeZ3JodCAtQy_Xh53pwHLEkf-7u2t8wWgj8NnU0Ag@mail.gmail.com>
Hello Yao,
> There is no such error with i686-w64-mingw32-g++ 5.3.1. Can we use "open"
> instead?
A fixed filename works most of the time but I'd rather use a temporary file if possible.
> > +/* Test that the file descriptor is closed. */ static void
> > +test_destroy () {
> > + char filename[] = "scoped_fd-selftest-XXXXXX";
> > + int fd = mkstemp (filename);
> > + SELF_CHECK (fd >= 0);
>
> Hi Markus,
> I failed to build this file with i686-w64-mingw32-g++ 4.8.2, shipped in Ubuntu
> 14.04.
>
> gdb/unittests/scoped_fd-selftests.c:37:29: error: ‘mkstemp’ was not declared in
> this scope
> int fd = mkstemp (filename);
> ^
This is supposed to be a glibc function. But it is guarded by some feature macros.
Quote from mkstemp(3): "
mkstemp():
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200112L
mkostemp(): _GNU_SOURCE
mkstemps(): _BSD_SOURCE || _SVID_SOURCE
mkostemps(): _GNU_SOURCE
"
Maybe the newer compiler is setting some macros automatically that the older compiler doesn't set.
Could you try setting, say, _POSIX_C_SOURCE or try using mkostemp() instead of mkstemp()?
If that doesn't help, I'll try to find a Ubuntu 14.04 to reproduce the issue.
thanks,
Markus.
> -----Original Message-----
> From: Yao Qi [mailto:qiyaoltc@gmail.com]
> Sent: 13 February 2018 17:48
> To: Metzger, Markus T <markus.t.metzger@intel.com>
> Cc: GDB Patches <gdb-patches@sourceware.org>
> Subject: Re: [PATCH v2 1/7] common: add scoped_fd
>
> On Fri, Jan 26, 2018 at 2:14 PM, Markus Metzger <markus.t.metzger@intel.com>
> wrote:
> > +
> > +/* Test that the file descriptor is closed. */ static void
> > +test_destroy () {
> > + char filename[] = "scoped_fd-selftest-XXXXXX";
> > + int fd = mkstemp (filename);
> > + SELF_CHECK (fd >= 0);
>
> Hi Markus,
> I failed to build this file with i686-w64-mingw32-g++ 4.8.2, shipped in Ubuntu
> 14.04.
>
> gdb/unittests/scoped_fd-selftests.c:37:29: error: ‘mkstemp’ was not declared in
> this scope
> int fd = mkstemp (filename);
> ^
> gdb/unittests/scoped_fd-selftests.c: In function ‘void
> selftests::scoped_fd::test_release()’:
> gdb/unittests/scoped_fd-selftests.c:56:29: error: ‘mkstemp’ was not declared in
> this scope
> int fd = mkstemp (filename);
> ^
>
> There is no such error with i686-w64-mingw32-g++ 5.3.1. Can we use "open"
> instead?
>
> --
> Yao (齐尧)
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928