A backslash in C++
-
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. -
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.ouch :(
'--8<------------------------ Ex Datis: Duncan Jones Free eBook: Printing - a .NET Developer's Guide (Part 1)
-
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.An interesting way to hide intentiously introduced errors from being discovered... ;) By the way, how does it come that compilation did not fail?
-
An interesting way to hide intentiously introduced errors from being discovered... ;) By the way, how does it come that compilation did not fail?
Oops! It was like this:
// Sometimes carry out the work \
if (flag)
{
SomeWork();
} -
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.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
-
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
That's assuming that the coder was using an IDE that supports colourisation. I know many C++ coders who work almost exclusively in Notepad++.
-
Oops! It was like this:
// Sometimes carry out the work \
if (flag)
{
SomeWork();
}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();
} -
That's assuming that the coder was using an IDE that supports colourisation. I know many C++ coders who work almost exclusively in Notepad++.
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
-
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
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.
-
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.
-
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.
-
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.
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
-
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.
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
-
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
That is pretty cool. I didn't know you could do that.
-
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.
-
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.
I started off my professional programming career using vi as my editor. Ah, for the days of :wq.
-
I started off my professional programming career using vi as my editor. Ah, for the days of :wq.
-
that really sounds like pain, but it's painfull to deal with IDE bugs and slowdowns too, so maybe you're right :^)
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.
-
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.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).
-
I started off my professional programming career using vi as my editor. Ah, for the days of :wq.
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. =========================================================