Announcement

Collapse
No announcement yet.

GCC 12 Adds Support For New #elifdef #elifndef Directives

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GCC 12 Adds Support For New #elifdef #elifndef Directives

    Phoronix: GCC 12 Adds Support For New #elifdef #elifndef Directives

    With C2X and potentially a future version of C++, there is finally the #elifdef and #elifndef directives. The GNU Compiler Collection is preparing its support...

    https://www.phoronix.com/scan.php?pa...ifdef-elifndef

  • #2
    Cnat wait to see code like this:
    Code:
    #ifdef HUGO
    
    dothehugo();
    
    #if __GNUC__ >= 12 || __cplusplus >= 20120000
    #elifdef FOO
    #else
    #elif defined(FOO)
    #endif
    
    dothefoo();
    
    #endif
    Seriously, it should've been there from the start, but adding it now it ridiculous

    Comment


    • #3
      Originally posted by discordian View Post
      Cnat wait to see code like this:
      LOL. That obviously won't work, of course.

      Originally posted by discordian View Post
      Seriously, it should've been there from the start, but adding it now it ridiculous
      I take a different view. I think #ifdef is too easily confused with #if. I'd rather they left it to just #if. It's a frequent point of confusion for neophyte C/C++ programmers, and even something you occasionally see more experienced types mess up.

      #if defined( FOO )

      isn't an unreasonable amount of typing.

      Comment


      • #4
        It has to be added at some point for it to be widespread. We'll be able to use it on public headers in 20 years, like we can use `//` and stdint.h for the most part today.

        Comment


        • #5
          Honestly it is time for the committee to recess. For five or ten years. Until there is something important to worry about.

          Comment


          • #6
            Originally posted by discordian View Post
            Seriously, it should've been there from the start, but adding it now it ridiculous
            Exactly so. Its absence has had literally no negative impact on the language for decades, and adding it is of absolutely no benefit at all at this stage.

            But, meh - it's not actively HARMFUL either, just petty and stupid. If the committee is so idle and so bored that they need to chase make-work like this, then hopefully everything that DOES actually matter is in pretty good shape.

            Comment


            • #7
              Originally posted by arQon View Post

              Exactly so. Its absence has had literally no negative impact on the language for decades, and adding it is of absolutely no benefit at all at this stage.

              But, meh - it's not actively HARMFUL either, just petty and stupid. If the committee is so idle and so bored that they need to chase make-work like this, then hopefully everything that DOES actually matter is in pretty good shape.
              It can cause headers to become accidentily restricted to specific modern compilers, when there is no reason for that. There is a clear risk of harm.

              Comment


              • #8
                Originally posted by coder View Post
                I think #ifdef is too easily confused with #if. I'd rather they left it to just #if.
                it's hard to leave it to just
                Code:
                #if defined
                when
                Code:
                #ifdef
                was invented before
                Code:
                #if defined

                Originally posted by coder View Post
                #if defined( FOO )


                isn't an unreasonable amount of typing.
                it contains 3 unnecessary characters(parens and space)
                Last edited by pal666; 14 May 2021, 06:01 PM.

                Comment


                • #9
                  Originally posted by arQon View Post
                  If the committee is so idle and so bored that they need to chase make-work like this, then hopefully everything that DOES actually matter is in pretty good shape.
                  all things which are both exciting and easy to do were done long ago. now exciting things are hard. subj is pretty easy

                  Comment


                  • #10
                    Originally posted by carewolf View Post
                    It can cause headers to become accidentily restricted to specific modern compilers
                    like every other new feature. so instead of crying you build your project with oldest supported compiler on ci. and btw this feature will not be even enabled without relevant -std= option. if you build your project with -std=c++23, then you clearly want to restrict to specific modern compilers
                    Originally posted by carewolf View Post
                    , when there is no reason for that.
                    if there's no reason you wouldn't use feature
                    Originally posted by carewolf View Post
                    There is a clear risk of harm.
                    only for people who have no chances anyway
                    Last edited by pal666; 14 May 2021, 05:53 PM.

                    Comment

                    Working...
                    X