According to ISO 7185 and ISO 10206 standard, GNU Pascal recognizes
by default comments opened with (*
and closed with }
.
With Borland Pascal, both types of comments can be nested, so
you will probably have sources where passages containing
comments are "commented out".
To use this with GPC, you have to "switch on" nested comments either by a command-line option, or by a compiler directive:
--nested-comments {$N+} (*$N+*)
The $N directive also exists in BP but has another meaning. The same holds for most of GPC's other compiler directives (also corresponding to command-line options in most cases):
--short-circuit $B+ $B- like in Borland Pascal: $B- means short-circuit Boolean operators; $B+ complete evaluation --c-numbers $C+ $C- enable/disable C-style octal 0177 and hexadecial 0xFF numbers --char-escapes $E+ $E- enable/disable C-style character escape sequences in strings --nested-comments $N+ $N- see above --pedantic $P+ $P- give/don't give warnings about violations of ISO 7185 Standard Pascal $W+ $W- enable/disable warnings $X+ $X- enable/disable extended syntax (function return value ignore, operator definitions) {$I FileName } include filename.pas or filename.p (make it lowercase) {$include "filename.pas"} include (case-sensitive) {$include <filename.pas>} the same, but don't search in current directory {$M Hello!} write message "Hello!" to error device during compilation {$D GNU} define GNU (for conditional {$define GNU} compilation) -D GNU the same in command line {$D loop while true do} define "loop" to be "while true do" as a macro like in C. It is case-sensitive. {$ifdef GNU} conditional compilation ... (like in Borland Pascal). {$else} GPC predefines the symbol ... __GPC__ (with two leading {$endif} and trailing underscores).
You also can use C-style preprocessor directives, e.g. #include.
As in Borland Pascal, {$...}
and (*$...*)
are equivalent.