T O P I C R E V I E W |
vortex |
Posted - Apr 07 2006 : 04:18:50 AM VA 1444, MSVS 2005
Surrounding code with coments by pressing '*', when option "Surround selection on /*( { and #" is on, corrupts existing C-style (/* */) comments in surrounding code.
Example. Before selecting and pressing '*':
After:
You see. In comments, which encloses 'a' parameter, we have redundant space symbol between '/' and '*'. If I press '*' one more time, this comments will be fixed, but often I remove VA autocomments by hand, and have corrupted my own code. |
9 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Apr 15 2006 : 4:48:07 PM some of my code has to compile under both Windows and UNIX. Windows is quite happy with no blank line at the bottom of the file, but the UNIX compiler will always flag this. |
jpizzi |
Posted - Apr 12 2006 : 5:45:21 PM The commenting out a block of text including the last line in the file has been mentioned before. It is a bug: case=414.
However, since a file that does not end in a new line is ill-formed according to the Standard, I suggest that you do everything you can to eliminate those cases. I have even seen cases where such a thing would cause compilation failures. |
vortex |
Posted - Apr 12 2006 : 05:36:49 AM ether About compilation failure of: /* void Foo(int /* a */) */ sorry, I don't draw attention to this.
feline Actually I don't use C-style comments, but problem comes from VAX ability to comment out the default values of function parameters in function definition (in .cpp files, for example) declared elsewere. For example we have following code:
--- my.h --- void A(int b = 10); --- end of my.h ---
--- my.cpp --- void A(int b /* = 0 */) { } --- end of my.cpp ---
I do not write all code in the parenthesis in .cpp file. I type "void A(" and press ctrl-enter. VA pastes needed code by itself.
And I discovered another bug concerned with comments (now C++ style: //). At the end of the source file, commenting block with "/" button won't work. Example:
void Foo(int a) { std::cout << a << std::end; } // <- Note: no newline here
If I select block of code including last line, and press "/" nothing happens. After placing newline after end of the function, in our example, commenting shortcut works as expected. |
feline |
Posted - Apr 08 2006 : 5:00:38 PM vortex i understand the problem, especially when you remove the /* */ comments by hand, i do this myself now and then.
this is why some programming books suggest that you use the // comment style as much as possible, since it does not have this problem.
can you try moving to using / on selected blocks instead of * ? this is the same single key press for you, but stops the problem happening. |
jpizzi |
Posted - Apr 07 2006 : 11:44:11 PM quote: That behavior is by design since nested C-style comments are usually illegal
And, amazingly enough, when you remove the outside comments (using the *, again), the "messed up" comment markers are restored!
I wonder how complex we can get with the nesting of comments before something messes up? |
feline |
Posted - Apr 07 2006 : 6:31:23 PM *checks* no, this does not compile in VS2005. it is coloured correctly, the comment ends before the close bracket, and the compiler picks up the unexpected close bracket. |
sean |
Posted - Apr 07 2006 : 12:22:33 PM That behavior is by design since nested C-style comments are usually illegal. Does the following compile in vs2005 (it doesn't in vs2003)?
/* void Foo(int /* a */) */
|
ether |
Posted - Apr 07 2006 : 12:22:28 PM The only problem with leaving your embedded comment alone is that the code will not compile.
//This will not compile because the */ after a will close the comment block!
/*
void Foo(int /* a */)
*/
This really shouldn't be a case, as I believe it is working the way it should be. |
rhummer |
Posted - Apr 07 2006 : 10:20:03 AM case=541
It's on the list to fix ;) |