public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60512] New: would be useful if gcc implemented __has_feature similary to clang
@ 2014-03-12 19:24 eteran at alum dot rit.edu
  2014-03-12 19:35 ` [Bug c++/60512] " glisse at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: eteran at alum dot rit.edu @ 2014-03-12 19:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60512

            Bug ID: 60512
           Summary: would be useful if gcc implemented __has_feature
                    similary to clang
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eteran at alum dot rit.edu

I was recently thinking about how GCC sets __cplusplus to 201103L when
-std=c++11 yet doesn't (and may not ever) fully support every single corner
case of c++11.

I agree with the notion that __cplusplus == 201103L is a statement of intent,
not 100% conformance. But how should developers write code that attempts to use
features which aren't necessarily implemented yet, but may be in the near
future or other compilers.

It occurred to me that the ideal solution may not be to test __cplusplus at
all, but instead to test for specific features. I find that that clang's
approach to this seems to hit the sweet spot. I'm sure the GCC folk are aware
of the feature, but I'll reiterate for reference. In clang:

"[This] function-like macro take a single identifier argument that is the name
of a feature. __has_feature evaluates to 1 if the feature is both supported by
Clang and standardized in the current language standard or 0 if not"

So while GCC doesn't support C++11 attributes yet, we could still code for it
today wrapping it like so.

    #if __has_feature(cxx_attributes)
    #endif

if it also supported the __has_feature (and family) suite of macros. Perhaps
this macro is mostly of interest to library writers and not a huge deal to most
developers, but I believe that it would be a tool that is *very* useful when it
turns out that you do need it.


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

end of thread, other threads:[~2023-12-11 21:53 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-12 19:24 [Bug c++/60512] New: would be useful if gcc implemented __has_feature similary to clang eteran at alum dot rit.edu
2014-03-12 19:35 ` [Bug c++/60512] " glisse at gcc dot gnu.org
2014-03-12 19:36 ` pinskia at gcc dot gnu.org
2014-03-12 19:52 ` eteran at alum dot rit.edu
2014-03-12 20:16 ` glisse at gcc dot gnu.org
2023-01-03 16:41 ` acoplan at gcc dot gnu.org
2023-01-04 11:40 ` redi at gcc dot gnu.org
2023-01-06 14:50 ` jrtc27 at jrtc27 dot com
2023-02-02 16:43 ` jason at gcc dot gnu.org
2023-04-11 16:39 ` acoplan at gcc dot gnu.org
2023-05-05 16:31 ` acoplan at gcc dot gnu.org
2023-05-05 18:03 ` iains at gcc dot gnu.org
2023-05-05 18:19 ` iains at gcc dot gnu.org
2023-05-05 20:26 ` iains at gcc dot gnu.org
2023-05-09 10:37 ` [Bug c++/60512] would be useful if gcc implemented __has_feature similarly " acoplan at gcc dot gnu.org
2023-05-09 10:57 ` iains at gcc dot gnu.org
2023-05-09 11:13 ` iains at gcc dot gnu.org
2023-05-09 12:14 ` acoplan at gcc dot gnu.org
2023-11-27 10:46 ` cvs-commit at gcc dot gnu.org
2023-11-27 11:08 ` acoplan at gcc dot gnu.org
2023-12-11 21:53 ` egallager 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).