Jamie
Jamie

Reputation: 3172

Delphi 2009 where is the 'treat warnings as errors' option?

In Delphi 2009 whereabouts do you turn on the option to treat warnings as errors?

Upvotes: 16

Views: 1919

Answers (3)

user424855
user424855

Reputation: 233

The point about -W^ being problematic within BAT files is a good one. Using -W^^ works if you are modifying the compile line directly. Otherwise, I found that using surrounding double quotes "-W^" works, for example when building an env var that contains all compiler parameters, that env var being subsequently passed to dcc32.exe. Tested with XE, XE2, XE3, XE4.

SET CompilerParams=-B -M "-W^" -U"..\Source;%dcuoutdir%;%DUnitPath%" -I"..\Source\inc" "-N0%dcuoutdir%" -DDebugMode
"%dcc%bin\dcc32.exe" %FuTFolder%ADDTests.dpr %CompilerParams% -U"%FuTSource%" %ExtraPath32%>%DCCLogFilename%
if errorlevel 1 %Alerter% %DCCLogFilename%

Upvotes: 2

Mark Edington
Mark Edington

Reputation: 6732

On a related note, if you are using the command line compiler (DCC32.exe) the switch is -W^ to have warnings treated as errors. If you are using this, it's important to note that the default command shell in Windows (cmd.exe) treats the caret (^) as an escape character, so you have to use -W^^ instead if you are executing the compiler directly from the command line, a batch file or even the from the Pre-Build or Post-Build events in the IDE.

It's also worth mentioning that you can have only certain warnings treated as errors. The switch to do this on the command line would look something like this: -W^^WARNING-NAME. You would substitute the string that is associated with the warning you are wanting to have treated as an error.

Upvotes: 15

Jamie
Jamie

Reputation: 3172

Just found the answer soon after I posted this! Might be useful for other people.

Navigate to 'Project -> Options - > Delphi Compiler -> Hints and Warnings' and change the value of 'Output Warnings' to 'as errors'

I was looking for an option similar to what Visual Studio has

Upvotes: 20

Related Questions