Fabio Gomes
Fabio Gomes

Reputation: 6022

Where should I set compiler options like {$STRINGCHECKS OFF}?

If I place it in the .dpr or any other unit will it be considered globally?

Upvotes: 0

Views: 922

Answers (4)

Craig Stuntz
Craig Stuntz

Reputation: 126547

Project -> Options -> Delphi Compiler -> Code generation, set "String format checking" OFF.

Upvotes: 5

Giel
Giel

Reputation: 2076

IIRC you can turn it off globally in the Project Options window.

Upvotes: 2

Ken White
Ken White

Reputation: 125651

Some compiler directives have different scope than others. Some affect the entire application, some only the unit they're put in, and some only the code around which they're placed. For example,

{$WARNINGS OFF}  // Turn off warning messages from compiler
procedure SomeProcedureThatHasAnAsmBlock;
begin
  asm
    // Some assembler code that generates warnings, but
    // that you know is actually right. These warnings
    // are usually like "expression always evaluates to false"
    // or something like that.
  end;
end;
{$WARNINGS ON}   // Turn warnings back on for other code

Since {$STRINGCHECKS} is undocumented (at least in the version of the D2009 help file I have), it's hard to know what it's scope is. Barry Kelly of CodeGear is here sometimes, and he works on the compiler itself; maybe he'll wander by and be able to help.

Upvotes: 3

Brian Frost
Brian Frost

Reputation: 13454

I dont think so. IIRC the rule is that anything in the dpr or unit is local to that file. If you put it into the project options (under conditionals) then it is global. Many writers put such stuff into a text file and then do a {$I MyConditionals.txt} at the top of each unit.

Upvotes: 5

Related Questions