Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-10

Precedence of compiler switches/directives

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Peter

I'm curious about who wins, if switches/directives are set to different values in different places. They could be set in
fpg.cfg
Command line or Lazarus lpi
Directives in the code.

Is there some AND/OR logic, or is it a strict precedence order? Is it the same for all switches? I can see for example that some switches can be turned on but not off at the command line.

I gather command line options take precedence over fpc.cfg, but what about directives in the code?  If a directive says range checks off, but the command line and/or fpc.cfg says range check on, what happens?

I assume that as directives can be set to different values in different parts of the code, that they must have the highest precedence. Is this correct and always the case?

Peter

Reply by email

Michael Van Canneyt
to Peter
Peter wrote 11 lines
I'm curious about who wins, if switches/directives are set to different values in different places. They could be set in fpg.cfg Command line or Lazarus lpi Directives in the code. Is there some AND/OR logic, or is it a strict precedence order? Is it the same for all switches? I can see for example that some switches can be turned on but not off at the command line. I gather command line options take precedence over fpc.cfg, but what about directives in the code?  If a directive says range checks off, but the command line and/or fpc.cfg says range check on, what happens?

The directive wins.

I assume that as directives can be set to different values in different parts of the code, that they must have the highest precedence. Is this correct and always the case?

I think the rule is best summarized as: The last set value always wins. That's why the order of options in the command-line is important.

Michael.

Reply by email