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. A backslash in C++

A backslash in C++

Scheduled Pinned Locked Moved The Weird and The Wonderful
c++help
41 Posts 17 Posters 1 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.
  • T Tsuda Kageyu

    My co-worker was struggling with a bug in an old C++ program.

    // Sometimes carry out the work \
    if (flag) {
    SomeWork();
    }

    SomeWork() was called regardless of the value of flag. It took her a few hours to find a backslash at the end of the comment.

    A Offline
    A Offline
    Argonia
    wrote on last edited by
    #5

    In this case the

    if (flag)

    would be colored in green showing that its part of the comment and it wont be read by the compiler. This should be enough of hint why SomeWork() is executed no matter the flag's value :)

    Microsoft ... the only place where VARIANT_TRUE != true

    P 1 Reply Last reply
    0
    • A Argonia

      In this case the

      if (flag)

      would be colored in green showing that its part of the comment and it wont be read by the compiler. This should be enough of hint why SomeWork() is executed no matter the flag's value :)

      Microsoft ... the only place where VARIANT_TRUE != true

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #6

      That's assuming that the coder was using an IDE that supports colourisation. I know many C++ coders who work almost exclusively in Notepad++.

      A 1 Reply Last reply
      0
      • T Tsuda Kageyu

        Oops! It was like this:

        // Sometimes carry out the work \
        if (flag)
        {
        SomeWork();
        }

        B Offline
        B Offline
        Bernhard Hiller
        wrote on last edited by
        #7

        Ah, then it's an interesting variant of

        // Sometimes carry out the work
        if (flag and some more long conditions filling more than the width of the screen);
        {
        SomeWork();
        }

        1 Reply Last reply
        0
        • P Pete OHanlon

          That's assuming that the coder was using an IDE that supports colourisation. I know many C++ coders who work almost exclusively in Notepad++.

          A Offline
          A Offline
          Argonia
          wrote on last edited by
          #8

          Nodepad++ supports coloring. I just tested and it changed the color of the if statement to green. Note: you need to save the file with the proper extension to enable the coloring of the text. Edit : Even with Borland c++ and djgpp compilers under dos you still have the proper coloring

          Microsoft ... the only place where VARIANT_TRUE != true

          P 1 Reply Last reply
          0
          • A Argonia

            Nodepad++ supports coloring. I just tested and it changed the color of the if statement to green. Note: you need to save the file with the proper extension to enable the coloring of the text. Edit : Even with Borland c++ and djgpp compilers under dos you still have the proper coloring

            Microsoft ... the only place where VARIANT_TRUE != true

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #9

            And what about those hard core devs who swear by (instead of at) vi? My point wasn't that Notepad++ supports or does not support colourisation. It's that you can't rely on colourisation to indicate problems.

            S A C 3 Replies Last reply
            0
            • P Pete OHanlon

              And what about those hard core devs who swear by (instead of at) vi? My point wasn't that Notepad++ supports or does not support colourisation. It's that you can't rely on colourisation to indicate problems.

              S Offline
              S Offline
              Sentenryu
              wrote on last edited by
              #10

              You can if you're not masochist ;P

              P 1 Reply Last reply
              0
              • S Sentenryu

                You can if you're not masochist ;P

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #11

                Hey, I like vi. There are parts of it that I wish were available in Visual Studio. dd for instance. Or 10dd to delete 10 lines. Yes, you can do this using other means in an IDE, but they are all more cumbersome.

                A S B L 4 Replies Last reply
                0
                • P Pete OHanlon

                  And what about those hard core devs who swear by (instead of at) vi? My point wasn't that Notepad++ supports or does not support colourisation. It's that you can't rely on colourisation to indicate problems.

                  A Offline
                  A Offline
                  Argonia
                  wrote on last edited by
                  #12

                  If you are programmer with not enough background with the language i don't thing that the best practice is to disable the coloring of the text. I think that the language itself it is not so easy to do such practice. And beside that coloring can save you hours of debugging in some cases like this for example. A enough experienced c++ / colorblind programmer can disable the coloring without lowering his or hers productivity.

                  Microsoft ... the only place where VARIANT_TRUE != true

                  N 1 Reply Last reply
                  0
                  • P Pete OHanlon

                    Hey, I like vi. There are parts of it that I wish were available in Visual Studio. dd for instance. Or 10dd to delete 10 lines. Yes, you can do this using other means in an IDE, but they are all more cumbersome.

                    A Offline
                    A Offline
                    Argonia
                    wrote on last edited by
                    #13

                    I have some exp with vi. I didn't see any particular bonuses which will make me change the compiler, but q! has his advantages ;) syntax coloring in vi and vim :-\

                    Microsoft ... the only place where VARIANT_TRUE != true

                    P 1 Reply Last reply
                    0
                    • A Argonia

                      I have some exp with vi. I didn't see any particular bonuses which will make me change the compiler, but q! has his advantages ;) syntax coloring in vi and vim :-\

                      Microsoft ... the only place where VARIANT_TRUE != true

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #14

                      That is pretty cool. I didn't know you could do that.

                      1 Reply Last reply
                      0
                      • P Pete OHanlon

                        Hey, I like vi. There are parts of it that I wish were available in Visual Studio. dd for instance. Or 10dd to delete 10 lines. Yes, you can do this using other means in an IDE, but they are all more cumbersome.

                        S Offline
                        S Offline
                        Sentenryu
                        wrote on last edited by
                        #15

                        I just can't get myself to tolerate vi, maybe because my only contact with it was on a old debian distro on my SO class, but the ammount of work needed to edit a simple 2 line key:value file threw me off.

                        P 1 Reply Last reply
                        0
                        • S Sentenryu

                          I just can't get myself to tolerate vi, maybe because my only contact with it was on a old debian distro on my SO class, but the ammount of work needed to edit a simple 2 line key:value file threw me off.

                          P Offline
                          P Offline
                          Pete OHanlon
                          wrote on last edited by
                          #16

                          I started off my professional programming career using vi as my editor. Ah, for the days of :wq.

                          S C 2 Replies Last reply
                          0
                          • P Pete OHanlon

                            I started off my professional programming career using vi as my editor. Ah, for the days of :wq.

                            S Offline
                            S Offline
                            Sentenryu
                            wrote on last edited by
                            #17

                            that really sounds like pain, but it's painfull to deal with IDE bugs and slowdowns too, so maybe you're right :^)

                            P 1 Reply Last reply
                            0
                            • S Sentenryu

                              that really sounds like pain, but it's painfull to deal with IDE bugs and slowdowns too, so maybe you're right :^)

                              P Offline
                              P Offline
                              Pete OHanlon
                              wrote on last edited by
                              #18

                              We didn't have IDE's on Unix systems when I started. I'm, what's the word I'm looking for? Oh yes, I'm old.

                              N S 2 Replies Last reply
                              0
                              • T Tsuda Kageyu

                                My co-worker was struggling with a bug in an old C++ program.

                                // Sometimes carry out the work \
                                if (flag) {
                                SomeWork();
                                }

                                SomeWork() was called regardless of the value of flag. It took her a few hours to find a backslash at the end of the comment.

                                P Offline
                                P Offline
                                Pablo Aliskevicius
                                wrote on last edited by
                                #19

                                The compilers I've used give a warning in cases like this. JM2B,

                                Pablo. "Accident: An inevitable occurrence due to the action of immutable natural laws." (Ambrose Bierce, circa 1899). "You are to act in the light of experience as guided by intelligence" (Rex Stout, "In the Best Families", 1950).

                                S 1 Reply Last reply
                                0
                                • P Pete OHanlon

                                  I started off my professional programming career using vi as my editor. Ah, for the days of :wq.

                                  C Offline
                                  C Offline
                                  Chris Quinn
                                  wrote on last edited by
                                  #20

                                  A good while ago I worked in a department where we did software development on both MSDos and Unix boxes. On the Dos boxes we used a realy good text editor called MultiEdit. One developer asked if I could get him MultiEdit for Unix - I replied no, but said that I couod get him vi for Dos - he nearly punched me!

                                  ========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================

                                  1 Reply Last reply
                                  0
                                  • P Pete OHanlon

                                    We didn't have IDE's on Unix systems when I started. I'm, what's the word I'm looking for? Oh yes, I'm old.

                                    N Offline
                                    N Offline
                                    Nagy Vilmos
                                    wrote on last edited by
                                    #21

                                    Yup, no argument from here. BTW, IIRC in vi you can write and exit with only three key strokes - [ESC]ZZ - rather than the cumbersome five of [ESC]:wq[ENTER].

                                    speramus in juniperus

                                    1 Reply Last reply
                                    0
                                    • A Argonia

                                      If you are programmer with not enough background with the language i don't thing that the best practice is to disable the coloring of the text. I think that the language itself it is not so easy to do such practice. And beside that coloring can save you hours of debugging in some cases like this for example. A enough experienced c++ / colorblind programmer can disable the coloring without lowering his or hers productivity.

                                      Microsoft ... the only place where VARIANT_TRUE != true

                                      N Offline
                                      N Offline
                                      Nagy Vilmos
                                      wrote on last edited by
                                      #22

                                      When you become practised in the art then you simply hold your hands above the keyboard in supplication and the code writes itself out of fear of reprisals. :cool:

                                      speramus in juniperus

                                      A C 2 Replies Last reply
                                      0
                                      • N Nagy Vilmos

                                        When you become practised in the art then you simply hold your hands above the keyboard in supplication and the code writes itself out of fear of reprisals. :cool:

                                        speramus in juniperus

                                        A Offline
                                        A Offline
                                        Argonia
                                        wrote on last edited by
                                        #23

                                        I can only dream of achieving such heights. :sigh:

                                        Microsoft ... the only place where VARIANT_TRUE != true

                                        1 Reply Last reply
                                        0
                                        • P Pete OHanlon

                                          We didn't have IDE's on Unix systems when I started. I'm, what's the word I'm looking for? Oh yes, I'm old.

                                          S Offline
                                          S Offline
                                          Sentenryu
                                          wrote on last edited by
                                          #24

                                          Well, I'm young and I run away from unix, so there's that :laugh:

                                          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