tags:

views:

343

answers:

4

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

+4  A: 

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.

Brian Frost
+2  A: 

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.

Ken White
+2  A: 

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

Giel
+5  A: 

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

Craig Stuntz