Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Yes, I know it's 2016

Yes, I know it's 2016

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpdata-structures
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #1

    but I just devised a cunning C macro. :cool: I may not be the first to devise this, but I'm likely the only one this decade. Many-a-day in years past I bemoaned that the argv array includes the name of the running executable and the resultant off-by-one confusion it caused me. So I was over-joyed to see that C# does away with that nonsense. Then today I was dabbling in some minor C code and so my depression returned. It occurred to me that all I wanted was something like the SHIFT command (DOS), so after a few minutes' thought, I wrote:

    # define SHIFT (++argv,--argc)

    I wrote it that way so it can be used in either of the following ways:

    SHIFT ;

    if ( argc > 0 ) { ... }

    while ( SHIFT > 0 ) { ... }

    switch ( SHIFT )
    {
    case 0 : { ... ; break ; }
    case 1 : { ... ; break ; }
    case 2 : { ... ; break ; }
    ...
    default : { ... ; break ; }
    }

    :badger:

    B L 2 Replies Last reply
    0
    • P PIEBALDconsult

      but I just devised a cunning C macro. :cool: I may not be the first to devise this, but I'm likely the only one this decade. Many-a-day in years past I bemoaned that the argv array includes the name of the running executable and the resultant off-by-one confusion it caused me. So I was over-joyed to see that C# does away with that nonsense. Then today I was dabbling in some minor C code and so my depression returned. It occurred to me that all I wanted was something like the SHIFT command (DOS), so after a few minutes' thought, I wrote:

      # define SHIFT (++argv,--argc)

      I wrote it that way so it can be used in either of the following ways:

      SHIFT ;

      if ( argc > 0 ) { ... }

      while ( SHIFT > 0 ) { ... }

      switch ( SHIFT )
      {
      case 0 : { ... ; break ; }
      case 1 : { ... ; break ; }
      case 2 : { ... ; break ; }
      ...
      default : { ... ; break ; }
      }

      :badger:

      B Offline
      B Offline
      Brisingr Aerowing
      wrote on last edited by
      #2

      :cool: I don't use C (or C++) much, though.

      What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

      P 1 Reply Last reply
      0
      • B Brisingr Aerowing

        :cool: I don't use C (or C++) much, though.

        What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Nor do I.

        1 Reply Last reply
        0
        • P PIEBALDconsult

          but I just devised a cunning C macro. :cool: I may not be the first to devise this, but I'm likely the only one this decade. Many-a-day in years past I bemoaned that the argv array includes the name of the running executable and the resultant off-by-one confusion it caused me. So I was over-joyed to see that C# does away with that nonsense. Then today I was dabbling in some minor C code and so my depression returned. It occurred to me that all I wanted was something like the SHIFT command (DOS), so after a few minutes' thought, I wrote:

          # define SHIFT (++argv,--argc)

          I wrote it that way so it can be used in either of the following ways:

          SHIFT ;

          if ( argc > 0 ) { ... }

          while ( SHIFT > 0 ) { ... }

          switch ( SHIFT )
          {
          case 0 : { ... ; break ; }
          case 1 : { ... ; break ; }
          case 2 : { ... ; break ; }
          ...
          default : { ... ; break ; }
          }

          :badger:

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Is this for some place where you can't use getopt? (like not supported by the compiler, or want to keep the binary size small?)

          P 1 Reply Last reply
          0
          • L Lost User

            Is this for some place where you can't use getopt? (like not supported by the compiler, or want to keep the binary size small?)

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            No, but I expect it can be used with it if you want, but that looks dreadful.

            R 1 Reply Last reply
            0
            • P PIEBALDconsult

              No, but I expect it can be used with it if you want, but that looks dreadful.

              R Offline
              R Offline
              Rob Grainger
              wrote on last edited by
              #6

              That was exactly my thought when I looked at getopt, but its somehow become the established standard for command-line processing on Unix-like systems. But then, that's elegant compared to the dog's do-do that is autoconf and the m4 macro-processor. Shudders.

              "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups