public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -Wzero-as-null-pointer-constant & extern "C" blocks
@ 2014-10-13 11:57 Daniel Llorens
  2014-10-13 12:02 ` Jonathan Wakely
  2014-10-16  3:30 ` Nick
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Llorens @ 2014-10-13 11:57 UTC (permalink / raw)
  To: gcc-help


Hello,

I tried using -Wzero-as-null-pointer-constant in a C++ program, but I got warnings in some C headers, even though they are wrapped in extern "C" blocks.

Since there is no nullptr in C, wouldn't it make more sense to disable the warning within those blocks? Is there some option that I'm missing?

Thanks,

	Daniel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -Wzero-as-null-pointer-constant & extern "C" blocks
  2014-10-13 11:57 -Wzero-as-null-pointer-constant & extern "C" blocks Daniel Llorens
@ 2014-10-13 12:02 ` Jonathan Wakely
  2014-10-13 12:27   ` Daniel Llorens
  2014-10-16  3:30 ` Nick
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2014-10-13 12:02 UTC (permalink / raw)
  To: Daniel Llorens; +Cc: gcc-help

On 13 October 2014 12:57, Daniel Llorens wrote:
>
> Hello,
>
> I tried using -Wzero-as-null-pointer-constant in a C++ program, but I got warnings in some C headers, even though they are wrapped in extern "C" blocks.
>
> Since there is no nullptr in C, wouldn't it make more sense to disable the warning within those blocks? Is there some option that I'm missing?

Although it's usually used in headers that need to be valid in both C
and C++, extern "C" does not mean you can't use C++ features.

extern "C" {
 void* ptr = nullptr;
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -Wzero-as-null-pointer-constant & extern "C" blocks
  2014-10-13 12:02 ` Jonathan Wakely
@ 2014-10-13 12:27   ` Daniel Llorens
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Llorens @ 2014-10-13 12:27 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-help


On 13 Oct 2014, at 14:02, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:

> On 13 October 2014 12:57, Daniel Llorens wrote:

>> I tried using -Wzero-as-null-pointer-constant in a C++ program, but I got warnings in some C headers, even though they are wrapped in extern "C" blocks.
>> 
>> Since there is no nullptr in C, wouldn't it make more sense to disable the warning within those blocks? Is there some option that I'm missing?
> 
> Although it's usually used in headers that need to be valid in both C
> and C++, extern "C" does not mean you can't use C++ features.
> 
> extern "C" {
> void* ptr = nullptr;
> }

Makes sense, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -Wzero-as-null-pointer-constant & extern "C" blocks
  2014-10-13 11:57 -Wzero-as-null-pointer-constant & extern "C" blocks Daniel Llorens
  2014-10-13 12:02 ` Jonathan Wakely
@ 2014-10-16  3:30 ` Nick
  1 sibling, 0 replies; 4+ messages in thread
From: Nick @ 2014-10-16  3:30 UTC (permalink / raw)
  To: Daniel Llorens; +Cc: gcc-help


On Mon, 2014-10-13 at 13:57 +0200, Daniel Llorens wrote:
> Hello,
> 
> I tried using -Wzero-as-null-pointer-constant in a C++ program, but I got warnings in some C headers, even though they are wrapped in extern "C" blocks.
> 
> Since there is no nullptr in C, wouldn't it make more sense to disable the warning within those blocks? Is there some option that I'm missing?
> 

If the C headers are separated, you may be able to use -isystem to
locate them (instead of -I) which suppresses some warnings.


Nick


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-16  3:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-13 11:57 -Wzero-as-null-pointer-constant & extern "C" blocks Daniel Llorens
2014-10-13 12:02 ` Jonathan Wakely
2014-10-13 12:27   ` Daniel Llorens
2014-10-16  3:30 ` Nick

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 read-only IMAP folder(s) and NNTP newsgroup(s).