View Issue Details

IDProjectCategoryView StatusLast Update
0034532FPCDocumentationpublic2018-11-12 13:14
ReporterThaddy de KoningAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformallOSallOS Versionall
Product Version3.3.1Product Build 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034532: Comments inside {$ifdef X the rest is comment} are not documented
DescriptionThis is legal syntax and exists for years:
begin
{$ifdef CPUARM this code is for arm only} // everything after CPUARM is a comment
  writeln ('arm');
{$endif arm specific code} // everything after arm is a comment.
end.

Problem is that some people do not realize that and expect something else, like
program untitled;
{.$define red}
{$define blue}
begin
{$ifdef red or $ifdef blue} // everything after red is a comment
  writeln ('read or blue');
{$endif red or blue} // everything after red is a comment.
end.
Steps To ReproduceSee the above code examples.
A documentation for this feature and a warning not to misinterpret this feature is probably warranted.

https://www.freepascal.org/docs-html/current/prog/progse4.html#x135-1360002.1
Additional InformationSee: http://forum.lazarus.freepascal.org/index.php/topic,43162.msg301645.html#msg301645
TagsNo tags attached.
Fixed in Revision1517
FPCOldBugId
FPCTarget
Attached Files

Activities

Thaddy de Koning

2018-11-10 09:01

reporter   ~0111884

Last edited: 2018-11-10 09:02

View 2 revisions

In both examples please read {$endif xxx xx xxx} // everything after *endif* is a comment. Sorry for the inconvenience.

Thaddy de Koning

2018-11-10 09:10

reporter   ~0111885

Better example:
program ifdefdemo;
begin
{$ifdef CPUARM this code is for arm only. Everything after CPUARM is a comment}
  writeln ('arm');
{$endif arm specific code. Everything after endif is a comment.}

{$define blue}
{ The following is not a compound boolean operation!
  $ifdef blue is a comment, not a define and will not be evaluated.}
{$ifdef red or $ifdef blue. Everything after red is a comment.}
  writeln ('read or blue');
{$endif red or blue. Everything after endif is a comment.}
end.

Michael Van Canneyt

2018-11-12 13:14

administrator   ~0111931

Documented, thanks for reporting.

Issue History

Date Modified Username Field Change
2018-11-10 08:53 Thaddy de Koning New Issue
2018-11-10 08:53 Thaddy de Koning Status new => assigned
2018-11-10 08:53 Thaddy de Koning Assigned To => Michael Van Canneyt
2018-11-10 09:01 Thaddy de Koning Note Added: 0111884
2018-11-10 09:02 Thaddy de Koning Note Edited: 0111884 View Revisions
2018-11-10 09:10 Thaddy de Koning Note Added: 0111885
2018-11-12 13:14 Michael Van Canneyt Fixed in Revision => 1517
2018-11-12 13:14 Michael Van Canneyt Note Added: 0111931
2018-11-12 13:14 Michael Van Canneyt Status assigned => resolved
2018-11-12 13:14 Michael Van Canneyt Fixed in Version => 3.3.1
2018-11-12 13:14 Michael Van Canneyt Resolution open => fixed
2018-11-12 13:14 Michael Van Canneyt Target Version => 3.2.0