linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ponnuvel Palaniyappan <pponnuvel@gmail.com>
To: Jonny Grant <jg@jguk.org>
Cc: Jakub Wilk <jwilk@jwilk.net>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	linux-man@vger.kernel.org
Subject: Re: gettid
Date: Wed, 17 Jun 2020 13:10:40 +0100	[thread overview]
Message-ID: <CAOL8xrW0O0gmVjx03ji9XEsLb_gg=zZ336P0Y=21KbKdOhM_vw@mail.gmail.com> (raw)
In-Reply-To: <cbbb7e4f-8774-c598-e9d3-6f13142dc3d3@jguk.org>

The default C++ mode, when no -std= is specified, for g++ 9.3.0 is
gnu++14 (it's the same for g++ 10.1.0, too).

> Looks like it is set by default, even when specifying the C++ standard version for g++
Why this happens is explained in libstd++'s faq:
https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.predefined


On Wed, Jun 17, 2020 at 12:14 PM Jonny Grant <jg@jguk.org> wrote:
>
>
>
> On 17/06/2020 11:22, Jakub Wilk wrote:
> > * Jonny Grant <jg@jguk.org>, 2020-06-16, 12:36:
> >> SYNOPSIS         top
> >>   #define _GNU_SOURCE
> >>   #include <unistd.h>
> >>   #include <sys/types.h>
> >>
> >>   pid_t gettid(void);
> >>
> >> I can compile on Ubuntu without #define _GNU_SOURCE and call gettid()
> >>
> >> Maybe that line can be removed?
> >
> > I don't think so. Here's what I get (with GCC 9):
> >
> >   $ gcc test.c
> >   test.c: In function ‘main’:
> >   test.c:6:9: warning: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Wimplicit-function-declaration]
> >       6 |  return gettid();
> >         |         ^~~~~~
> >         |         getgid
> >
> > Prepending "#define _GNU_SOURCE" fixes the above.
>
> Hi Jakub,
>
> Apologies, I should have shared my test case, I was compiling as C++
> // g++ -Wall -o tid tid.cpp
>
> #include <unistd.h>
> #include <sys/types.h>
>
> int main()
> {
>     return gettid();
> }
>
>
>
> $ g++ -Wall -o tid tid.cpp
> tid.cpp:3: warning: "_GNU_SOURCE" redefined
>     3 | #define _GNU_SOURCE
>       |
> <command-line>: note: this is the location of the previous definition
>
>
> Looks like it is set by default, even when specifying the C++ standard version for g++
> g++ -std=c++11 -Wall -o tid tid.cpp
>
>
> Checked, yes, if compiling as C, see the same result as you.
>
> Not sure how it gets enabled by default in my c++
>
> $ g++ --version
> g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0
>
> Cheers, Jonny
>
>


--
Regards,
Ponnuvel P

  reply	other threads:[~2020-06-17 12:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 11:36 gettid Jonny Grant
2020-06-17 10:22 ` gettid Jakub Wilk
2020-06-17 11:14   ` gettid Jonny Grant
2020-06-17 12:10     ` Ponnuvel Palaniyappan [this message]
2020-06-17 12:26       ` gettid Jonny Grant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOL8xrW0O0gmVjx03ji9XEsLb_gg=zZ336P0Y=21KbKdOhM_vw@mail.gmail.com' \
    --to=pponnuvel@gmail.com \
    --cc=jg@jguk.org \
    --cc=jwilk@jwilk.net \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).