Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/23/01 00:59
Read: times


 
#16844 - RE: Keil, MSVC, BCB - consensus
I have tried compiling the following in Keil C51 v6.10, MSVC, and Borland:
#define MAX(A,B)                ??/
  if( A > B )                   ??/
      return A; // A is biggest ??/
  else                          ??/
      return B; // B is biggest

int main( void )
{
	unsigned char a = 1;
	unsigned char b = 2;

	MAX( a, b )
}
In all cases, the preprocessor output is:
int main( void )
{
 unsigned char a = 1;
 unsigned char b = 2;

  if( a > b ) return a;
}
ie, the preprocessors have all, as I said, stripped the 'else' clause, as it falls within the "extended" comment caused by the backslash line splicing.

MSVC gives warning C4010, which is described in the online help as:
"single-line comment contains line-continuation character
A single-line comment (introduced by //) contains a line- continuation character (). The next line after the line- continuation character is ignored; it is considered to be the continuation of the previous line and is treated as a comment."


Borland gives warning W8010, which has a similar description:
" Continuation character found in // comment
This warning message is issued when a C++ // comment is continued onto the next line with backslash line continuation.
The intention is to warn about cases where lines containing source code unintentionally become part of a comment because that comment happened to end in a backslash.
If you get this warning, check carefully whether you intend the line after the // comment to be part of the comment. If you don't, either remove the backslash or put some other character after it. If you do, it's probably better coding style to start the next comment line with // also."


I don't have C51 v6.20 to hand at the moment; I'll try it tomorrow (Friday).

However, I maintain my original assertion that it is dangerous to use "//" comments in macro definitions, and especially so with line splicing.

List of 18 messages in thread
TopicAuthorDate
Keil's 6.20c problem with comments            01/01/70 00:00      
RE: Keil\'s 6.20c problem with comments            01/01/70 00:00      
RE: Keil\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\            01/01/70 00:00      
RE: Keil\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\            01/01/70 00:00      
RE: Keil            01/01/70 00:00      
RE: Keil            01/01/70 00:00      
RE: Keil            01/01/70 00:00      
RE: Keil comments - correction            01/01/70 00:00      
RE: Keil, MSVC, BCB - consensus            01/01/70 00:00      
RE: Keil\'s 6.20c problem with comments            01/01/70 00:00      
RE: Keil\'s 6.20c comments - Craig            01/01/70 00:00      
RE: Keil, MSVC, BCB - consensus            01/01/70 00:00      
RE: Keil, MSVC, BCB - consensus            01/01/70 00:00      
RE: Keil\\\'s 6.20c problem with comments            01/01/70 00:00      
RE: Keil, MSVC, BCB - consensus            01/01/70 00:00      
RE: Keil, MSVC, BCB - consensus            01/01/70 00:00      
RE: Keil, MSVC, BCB - Peter            01/01/70 00:00      
First things first!            01/01/70 00:00      

Back to Subject List