Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 1.4k
    • Issues 1.4k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 84
    • Merge requests 84
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
    • Model experiments
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • FPCFPC
  • FPC SourceFPC Source
  • Issues
  • #27529
Closed
Open
Issue created Feb 23, 2015 by FPC Admin account@fpc_adminOwner

-d macro value ignored in code

Original Reporter info from Mantis: p_daniel
  • Reporter name:

Description:

Documentation say that {$DEFINE ident:=expr} and command-line -dident:=expr are equivalent, but if you use the second, value of 'ident' available only in compile time expressions and have no effect in code.
For example:

program test;

{$IF DEFINED(MY_VAR)}
  {$INFO MY_VAR defined}
  {$IF MY_VAR=123}
    {$INFO MY_VAR = 123}
  {$ELSE}
    {$INFO MY_VAR <> 123}
  {$ENDIF}
{$ENDIF}

begin
  writeln(MY_VAR);
end.

===

fpc test.pas -Sm -dMY_VAR:=123
...
Compiling test.pas
User defined: MY_VAR defined
User defined: MY_VAR = 123
test.pas(15,17) Error: Identifier not found "MY_VAR"
test.pas(17) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

But if you declare {$DEFINE MY_VAR:=123} in code, all is Ok.

Steps to reproduce:

fpc test.pas -Sm -dMY_VAR:=123

Mantis conversion info:

  • Mantis ID: 27529
  • OS: Linux
  • Build: [2014/04/20] for x86_64
  • Platform: x86-64
  • Version: 2.6.4
  • Fixed in version: 3.1.1
  • Fixed in revision: 30271 (#3396e2e1)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking