LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Backlslashes in the IDE

Here's a little something that everyone should watch out for.  If you put a backslash at the end of a C++ style comment the compiler will consider the next line as part of the comment and will ignore it.  I believe this is perfectly valid behavior, but CVI's syntax highlighting doesn't show that line as being part of the comment so this can lead to some non-obvious bugs where lines of code appear to be "skipped over" in the debugger.

 

Here's a screenshot of some sample code in CVI.  Note that in this example the line b = 2 will not be compiled:

cvi.png

Here's the same code copied into Notepad++ with its syntax highlighting:

npp.png

 

Message 1 of 6
(3,017 Views)

Hi tstanley,

 

As you mentioned in the first part of your comment, this is expected behavior.  If you put a line continuation symbol \ at the end of a line, it effectively merges the two lines together. If you have a // comment block in the first line, that effectively causes the entire second line to also be part of the comment.  If you add any character after the \ symbol, it will no longer act as a line continuation symbol, and you won't have this problem.

Alternatively, you can use the /*Comment\ */ comment structure, and this error will not occur.

 

I hope this clears things up.

 

Warm Regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 2 of 6
(2,999 Views)

I wouldn't normally end a comment on a backslash like that, but I did it by accident - with the backslash key next to the ENTER key it's all too easy to fat-finger it.  Since CVI's syntax highlighter doesn't show the next line as a comment in this case it left me with a real head-scratcher until I realized what was going on.  A search of the project revealed one other place where that had happened, though luckily the resulting bug was minor.  It's just something to watch out for.

0 Kudos
Message 3 of 6
(2,991 Views)

Hi tstanley,

 

Thank you for your feedback!  I have filed this as a syntax highlighting bug in our system.  The syntax highlighting feature should include this.

 

Warm Regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 4 of 6
(2,988 Views)

I just encountered this bug with CVI 2017 version 17.0.0 (295)

I wonder if this bug is still present in later versions...

 

Very annoying bug!

 

0 Kudos
Message 5 of 6
(1,341 Views)

I just want to highlight that if you enable "Comment"  warning in the build options you will be notified in case a backslash exists in a c++-style comment line

Screenshot 2021-07-30 12.14.16.png



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 6
(1,335 Views)