public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__
@ 2015-08-12 17:59 noloader at gmail dot com
  2015-08-13  8:01 ` [Bug c++/67195] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: noloader at gmail dot com @ 2015-08-12 17:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67195

            Bug ID: 67195
           Summary: cpp and g++ does not define __GLIBCXX__
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: noloader at gmail dot com
  Target Milestone: ---

I'm trying to detect a debug build, and enjoy the benefit of additional
instrumentation:

    # Debug testing
    ifneq ($(filter -DDEBUG -DDEBUG=1 -O0 -O1 -Og,$(CXXFLAGS)),)
      CXXFLAGS += -D_GLIBCXX_DEBUG=1 -D_GLIBCXX_CONCEPT_CHECKS=1
    endif # Debug build

According to Chapter 3. Using Macros
(https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html):

    __GLIBCXX__

        The current version of libstdc++ in compressed ISO date format, as an
unsigned long.

However, on Fedora22 x86_64:

    $ cpp -x c++ -dM < /dev/null | grep -i lib
    $ cpp -x c++ -dM < /dev/null | grep -i c++
    #define __GLIBCXX_BITSIZE_INT_N_0 128
    #define __GLIBCXX_TYPE_INT_N_0 __int128
    $ cpp -x c++ -dM < /dev/null | grep -i cxx
    #define __GLIBCXX_BITSIZE_INT_N_0 128
    #define __GLIBCXX_TYPE_INT_N_0 __int128
    $ g++ -E -dM - < /dev/null | grep -i lib
    $ g++ -E -dM - < /dev/null | grep -i c++
    $ g++ -E -dM - < /dev/null | grep -i cxx
    $

-----

$ uname -a
Linux localhost.localdomain 4.1.3-201.fc22.x86_64 #1 SMP Wed Jul 29 19:50:22
UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ g++ --version
g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
Copyright (C) 2015 Free Software Foundation, Inc


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

* [Bug c++/67195] cpp and g++ does not define __GLIBCXX__
  2015-08-12 17:59 [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__ noloader at gmail dot com
@ 2015-08-13  8:01 ` redi at gcc dot gnu.org
  2015-08-13  8:42 ` noloader at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-13  8:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67195

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The library macro is defined by the library, not the compiler. You didn't
include any library headers.


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

* [Bug c++/67195] cpp and g++ does not define __GLIBCXX__
  2015-08-12 17:59 [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__ noloader at gmail dot com
  2015-08-13  8:01 ` [Bug c++/67195] " redi at gcc dot gnu.org
@ 2015-08-13  8:42 ` noloader at gmail dot com
  2015-08-13  9:06 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: noloader at gmail dot com @ 2015-08-13  8:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67195

--- Comment #2 from Jeffrey Walton <noloader at gmail dot com> ---

> 
> $ uname -a
> Linux localhost.localdomain 4.1.3-201.fc22.x86_64 #1 SMP Wed Jul 29 19:50:22
> UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> 
> $ g++ --version
> g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
> Copyright (C) 2015 Free Software Foundation, Inc

(In reply to Jonathan Wakely from comment #1)
> The library macro is defined by the library, not the compiler. You didn't
> include any library headers.

Thanks Jonathon.

The documentation does not state that requirement. Perhaps this is a
documentation bug?

------

Related, here's how I am trying to use it in a makefile:

USING_GLIBCXX := $(shell $(CXX) $(CXXFLAGS) -E -dM - </dev/null | $(EGREP) -i
-c "__GLIBCXX__")
$(info USING_GLIBCXX: $(USING_GLIBCXX))

# For debug builds
ifneq ($(USING_GLIBCXX),0)
CXXFLAGS += -D_GLIBCXX_DEBUG=1 --enable-concept-checks
endif

CXX and CXXFAGS are populated, and they hold the settings that will be used by
make to compile the source code. It kind of begs the question, how does CXX
know to use -stdlib=libstdc++ if its not specified in CXXFLAGS? Shouldn't
everything "just work" or everything "just fail"?


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

* [Bug c++/67195] cpp and g++ does not define __GLIBCXX__
  2015-08-12 17:59 [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__ noloader at gmail dot com
  2015-08-13  8:01 ` [Bug c++/67195] " redi at gcc dot gnu.org
  2015-08-13  8:42 ` noloader at gmail dot com
@ 2015-08-13  9:06 ` pinskia at gcc dot gnu.org
  2015-08-13  9:08 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-08-13  9:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67195

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jeffrey Walton from comment #2)
> > 
> > $ uname -a
> > Linux localhost.localdomain 4.1.3-201.fc22.x86_64 #1 SMP Wed Jul 29 19:50:22
> > UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> > 
> > $ g++ --version
> > g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
> > Copyright (C) 2015 Free Software Foundation, Inc
> 
> (In reply to Jonathan Wakely from comment #1)
> > The library macro is defined by the library, not the compiler. You didn't
> > include any library headers.
> 
> Thanks Jonathon.
> 
> The documentation does not state that requirement. Perhaps this is a
> documentation bug?

I think the document assumes that since this is the library docs rather than
the compiler or preprocessor doc n



> 
> ------
> 
> Related, here's how I am trying to use it in a makefile:
> 
> USING_GLIBCXX := $(shell $(CXX) $(CXXFLAGS) -E -dM - </dev/null | $(EGREP)
> -i -c "__GLIBCXX__")
> $(info USING_GLIBCXX: $(USING_GLIBCXX))
> 
> # For debug builds
> ifneq ($(USING_GLIBCXX),0)
> CXXFLAGS += -D_GLIBCXX_DEBUG=1 --enable-concept-checks
> endif
> 
> CXX and CXXFAGS are populated, and they hold the settings that will be used
> by make to compile the source code. It kind of begs the question, how does
> CXX know to use -stdlib=libstdc++ if its not specified in CXXFLAGS?
> Shouldn't everything "just work" or everything "just fail"?


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

* [Bug c++/67195] cpp and g++ does not define __GLIBCXX__
  2015-08-12 17:59 [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__ noloader at gmail dot com
                   ` (2 preceding siblings ...)
  2015-08-13  9:06 ` pinskia at gcc dot gnu.org
@ 2015-08-13  9:08 ` pinskia at gcc dot gnu.org
  2015-08-13 10:04 ` noloader at gmail dot com
  2015-08-13 14:42 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-08-13  9:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67195

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to Jeffrey Walton from comment #2)
> > > 
> > > $ uname -a
> > > Linux localhost.localdomain 4.1.3-201.fc22.x86_64 #1 SMP Wed Jul 29 19:50:22
> > > UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> > > 
> > > $ g++ --version
> > > g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
> > > Copyright (C) 2015 Free Software Foundation, Inc
> > 
> > (In reply to Jonathan Wakely from comment #1)
> > > The library macro is defined by the library, not the compiler. You didn't
> > > include any library headers.
> > 
> > Thanks Jonathon.
> > 
> > The documentation does not state that requirement. Perhaps this is a
> > documentation bug?
> 
> I think the document assumes that since this is the library docs rather than
> the compiler or preprocessor doc n
> 

Actually it is right in the second paragraph:
Furthermore, all pre-processor macros, switches, and configuration options are
gathered in the file c++config.h

What more is needed?


> 
> 
> > 
> > ------
> > 
> > Related, here's how I am trying to use it in a makefile:
> > 
> > USING_GLIBCXX := $(shell $(CXX) $(CXXFLAGS) -E -dM - </dev/null | $(EGREP)
> > -i -c "__GLIBCXX__")
> > $(info USING_GLIBCXX: $(USING_GLIBCXX))
> > 
> > # For debug builds
> > ifneq ($(USING_GLIBCXX),0)
> > CXXFLAGS += -D_GLIBCXX_DEBUG=1 --enable-concept-checks
> > endif
> > 
> > CXX and CXXFAGS are populated, and they hold the settings that will be used
> > by make to compile the source code. It kind of begs the question, how does
> > CXX know to use -stdlib=libstdc++ if its not specified in CXXFLAGS?
> > Shouldn't everything "just work" or everything "just fail"?


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

* [Bug c++/67195] cpp and g++ does not define __GLIBCXX__
  2015-08-12 17:59 [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__ noloader at gmail dot com
                   ` (3 preceding siblings ...)
  2015-08-13  9:08 ` pinskia at gcc dot gnu.org
@ 2015-08-13 10:04 ` noloader at gmail dot com
  2015-08-13 14:42 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: noloader at gmail dot com @ 2015-08-13 10:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67195

--- Comment #5 from Jeffrey Walton <noloader at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to Jeffrey Walton from comment #2)
> > > 
> > > $ uname -a
> > > Linux localhost.localdomain 4.1.3-201.fc22.x86_64 #1 SMP Wed Jul 29 19:50:22
> > > UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> > > 
> > > $ g++ --version
> > > g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
> > > Copyright (C) 2015 Free Software Foundation, Inc
> > 
> > (In reply to Jonathan Wakely from comment #1)
> > > The library macro is defined by the library, not the compiler. You didn't
> > > include any library headers.
> > 
> > Thanks Jonathon.
> > 
> > The documentation does not state that requirement. Perhaps this is a
> > documentation bug?
> 
> I think the document assumes that since this is the library docs rather than
> the compiler or preprocessor doc n

Yeah, I have the problem of "literal readings" in real life, too.

When I parsed the page on macros, I found it to be an interesting
implementation detail. And I thought it was useful to know cpp or g++ fetched
the macro from c++config.h. (A related factoid is LLVM uses <ciso646>).

But because I was not explicitly told to include c++config.h or another
standard library header for the define, I did not make the leap it was a
requirement.

For me (naively), 'cpp' or 'g++ -dM' provide the preporcessor macros used to
compile a source file, and the way they are delivered to me is
indistinguishable from magic.


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

* [Bug c++/67195] cpp and g++ does not define __GLIBCXX__
  2015-08-12 17:59 [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__ noloader at gmail dot com
                   ` (4 preceding siblings ...)
  2015-08-13 10:04 ` noloader at gmail dot com
@ 2015-08-13 14:42 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-13 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67195

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jeffrey Walton from comment #5)
> When I parsed the page on macros, I found it to be an interesting
> implementation detail. And I thought it was useful to know cpp or g++
> fetched the macro from c++config.h. (A related factoid is LLVM uses
> <ciso646>).

Technically it uses <__config>, which is its equivalent of our
<bits/c++config.h>. The reason they suggest including <ciso646> is that it's a
public header that does nothing except include the internal implementation
header <__config>.

> But because I was not explicitly told to include c++config.h or another
> standard library header for the define, I did not make the leap it was a
> requirement.
> 
> For me (naively), 'cpp' or 'g++ -dM' provide the preporcessor macros used to
> compile a source file, and the way they are delivered to me is
> indistinguishable from magic.

But for us it is done using sufficiently advanced technology not magic, and
that technology is a header file.

Since you could in theory be using g++ with a different standard library
implementation other than libstdc++ it would make no sense for g++ to define
the libstdc++ macros, and would be completely wrong! They have to come from the
library itself because only once you include a library header file is it known
which library you are using.


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

end of thread, other threads:[~2015-08-13 14:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12 17:59 [Bug c++/67195] New: cpp and g++ does not define __GLIBCXX__ noloader at gmail dot com
2015-08-13  8:01 ` [Bug c++/67195] " redi at gcc dot gnu.org
2015-08-13  8:42 ` noloader at gmail dot com
2015-08-13  9:06 ` pinskia at gcc dot gnu.org
2015-08-13  9:08 ` pinskia at gcc dot gnu.org
2015-08-13 10:04 ` noloader at gmail dot com
2015-08-13 14:42 ` redi at gcc dot gnu.org

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).