1.2 Comments

Free Pascal supports the use of nested comments. The following constructs are valid comments:

(* This is an old style comment *)  
{  This is a Turbo Pascal comment }  
// This is a Delphi comment. All is ignored till the end of the line.

The following are valid ways of nesting comments:

{ Comment 1 (* comment 2 *) }  
(* Comment 1 { comment 2 } *)  
{ comment 1 // Comment 2 }  
(* comment 1 // Comment 2 *)  
// comment 1 (* comment 2 *)  
// comment 1 { comment 2 }

The last two comments must be on one line. The following two will give errors:

 // Valid comment { No longer valid comment !!  
    }

and

 // Valid comment (* No longer valid comment !!  
    *)

The compiler will react with a ’invalid character’ error when it encounters such constructs, regardless of the -Mturbo switch.

Remark: In TP and Delphi mode, nested comments are not allowed, for maximum compatibility with existing code for those compilers.