How do I disable UNSAFE_CAST option? - delphi

I get a warning when i compile my project.
[DCC Warning] ...W1047 Unsafe code '^ operator'
On build info:
Target CoreCompile:
....\dcc32.exe -$W+ -$J+ --no-config ... -W+UNSAFE_TYPE -W+UNSAFE_CODE -W+UNSAFE_CAST
I know that I can set this off, but I can't find where todo this on delphi 2010.
On Project>Options>Delphi Compiler>Hint and Warnings: I have Unsafe code, unsafe type and unsafe typecast to false
Can somebody help me.

If the warnings are disabled in the IDE options dialog, then the command send to dcc32 will not enable them. Which leads me to believe that the warnings are enabled in the IDE options.
So, my guess is that you have multiple build configurations and are looking in the wrong build configuration in the IDE.
I always get confused by the way the IDE presents build configurations. You may find it easier to search the .dproj file in a text editor. Look for DCC_UNSAFE_CODE, DCC_UNSAFE_CAST and DCC_UNSAFE_TYPE. You can then delete all of those entries and your settings will revert to the default value, which is not to warn.

Related

How to Turn Off/On a WARN directive for the whole Delphi Project ?

In Delphi we have multiple warn the compiler the provide to protect you do do something bad. Some are errors other warns etc.
I want to turn off the Warn for SYMBOL_DEPRECATED for all my files in the project.
But I just found ways to do it by file ?
Project->Options->Hints and Warnings from the menu.
Change Deprecated Symbol in the list to False. You'll need to do it for each target (Debug Win32, Release Win32, etc.), as they're maintained separately.
(Not sure why you'd want to do that, BTW. Deprecated symbol warnings are meaningful, as opposed to the Platform Unit when you're clearly doing a VCL Windows app and not FMX. You should heed deprecated symbol warnings, as those mean that code can break in the future and you're not prepared.)

delphi d2009 update 3 dcc32 build options. Win XP

I have a seemingly unsolvable (to me!) problem.
If I start a simple vcl forms app and try to compile, I get multiple warning/errors as follows :
[DCC Warning] SysUtils.pas(6082): W1000 Symbol 'SInvalidInteger' is deprecated: 'Use SysConsts.SInvalidInteger'
etc.
[DCC Fatal Error] Variants.pas(1071): F2092 Program or unit 'Variants' recursively uses itself
The library path options both in the global and project sections seem Ok,
but if I hover over the dcc32.exe build or output messages, I can see a vast selection of
paths which are not relevant and also are repeated about 3 times.
The dcc32.cfg is quite short and seems Ok.
It looks like the path is corrupt somehow and although I've reinstalled D2009 (after deleting the program) and also cleared the registry, I cannot seem to solve this problem.
question : how can I reset or clear this dcc32.exe path - where is the option file, or is it created on the fly?
This problem occurred when I tried to compile a D7 project/or added JCL/jvcl (now removed)
Thanks for any ideas!

Xcode warning: ... is a GNU extension

I use a C++ library for an iOS app. With Apple LLVM 3.1 compiler configured (default), I get a lot of warnings for this C++ code, most of them saying:
... is a GNU extension
The introduction of clang's user manual says:
The Clang driver and language features are intentionally designed to be as compatible with the GNU GCC compiler as reasonably possible, easing migration from GCC to Clang. In most cases, code "just works".
So, is it save to just look for a switch to disable this warnings (btw. how to?) or should I better get this lib rid of all GNU extensions?
You can suppress the warnings using compiler flags. Clang tells you which compiler flag to use for each warning. After a build, choose View > Navigators > Show Log Navigator. Then choose the latest build log from the log navigator. Find a file with a warning and click the disclosure button at the right end of its status line. Xcode will show you the compiler command line and output for that file. Each warning should include the compiler flag that enables the warning. Example:
In my example, the warning flag is -Wpointer-arith. So the warning can be disabled by -Wno-pointer-arith. So I could add that flag to the “Other Warning Flags” build setting:

How do I stop the debugger from stepping into Delphi-supplied units?

The debugger steps into the source code on errors (like with F7), but I want to restore the normal working mode where the Delphi basic DCUs (the library) are only compiled into my code, and the sources are not used in debugging.
For example, on an error in my program, the debugger is stepping into Controls.pas, into TControl.Click. The normal case (right after installation) is for Delphi to step over these methods.
Should I recompile Controls.pas without debug information? If so, how?
I extending this theme with additional information to better understanding:
We use Delphi6 Prof. what have problem with Mouse (System Error Code 5).
So we want to recompile to Controls.pas to replace the Mouse Position getter code.
Then:
I created a folder for it: "c:\D\Common\Delphi_Patches\Delphi_6\"
I put the original Controls.pas into it.
I modified the Controls.pas, replaced the position getter code.
I set the Delphi's Library path, set the first folder to "c:\D\Common\Delphi_Patches\Delphi_6\"
With these steps I can compiled the source with mouse-safe code.
Ok, but then the Delphi everytime steps into Controls.pas on F7, and on any exceptions - this is very "angermaker" thing.
No matter that I removed the "Controls.pas" from the Library path - then the debugger is finding the original "Controls.pas" for it, and opens it... :-(
We don't use "Use Debug DCU-s" in any codes.
I tried to remove "Debug Information" from compiler options, but it is no matter, the Delphi is opens the original Controls.pas...
So I search the way to Delphi don't step into "Controls.pas", but use my dcu...
I hope this provide better context to understand the problem.
I think that you need to Shift+Ctrl+F11 (tools/options) then in Compiler, uncheck "Use debug DCU"...Then if an exception occurs it wont break into the RTL or VCL sources.
Since you are compiling your own version of a Delphi unit, you can disable debug info in that unit. Add {$D-} to the source code of the unit(s) in question.
As I see the solution is:
create a project the uses only the new Controls.pas.
unset the "Debug information" option in compiler options.
build dcu
put the dcu into a library folder
hide the new Controls.pas from this library folders.
Wite this trick the I cannot "step into" controls.pas.
Regards: dd
I had this same problem with Delphi XE8.
You can untick the "Project >> Option >> Compiling >> Use debug .dcus" and it will continue tracing into System unit and so on.
I found that the best way to stop this is to open your Application.dproj file - which is in XML. In it, you can change the settings as follows:
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<DCC_AssertionsAtRuntime>false</DCC_AssertionsAtRuntime> <--- note false
<DCC_DebugDCUs>false</DCC_DebugDCUs>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<DCC_RemoteDebug>false</DCC_RemoteDebug>
</PropertyGroup>

How to force Delphi compiler to display all hints and warnings

Is there a way to force the Delphi compiler to display all hints and warnings all the time?
Here is the behavior that I am currently seeing in Delphi 6:
Check out fresh copy of my application from source control
Open project in Delphi and Compile
All hints and warnings for the project are displayed
Make a change in one unit
Compile
Only the hints and warnings for the changed unit are displayed
So, I thought maybe I can trick Delphi by deleting all of the dcu files to force it to recompile everything. No luck. The compiler does in fact recompile all of the units, but does not display the hints and warnings for those units.
EDIT: Performing a full build (Project > Build) yields the same unfortunate results.
NEW INFORMATION: If I modify a unit and then Compile, I get the warnings. However, if I modify a unit and then Build, I do not get the warnings. I'm thinking this points to warnings being turned off somewhere. Possibly in a third party library?
It seems there ought to be a way to ask Delphi to re-display all of those hints and warnings that doesn't require me to either check out a fresh copy from source control or modify each unit one-by-one.
Hints and Warnings are generated by the compiler. It will only report on units that it has compiled. The "compile" command will only compile files that have changed. To force a recompilation of all units used by your project, use the Build command instead.
Later versions assign a shortcut key (Shift+F9) to the "Build" command.
To get that keyboard shortcut in Delphi 6, install this utility, which I've used for a while with great success on Delphi 5.
I would check to see if you turn the warnings off in some of your units.
Depending on the last change in the units, the compiling order can change. In some cases the warnings can remain disabled for a unit that is compiled after while, when freshly checked out of version control, it was compiled before, with the warnings.
Pay extra attention to any Include file you may use.
I had the same problem and finally i found solution... Search for strings $WARNINGS OFF and $HINTS OFF, and not just from *.pas files but from all the files. I had this strange idea in third-party .inc file:
{$IFDEF DEBUG}
{$WARNINGS ON}
{$HINTS ON}
{$ELSE}
{$WARNINGS OFF}
{$HINTS OFF}
{$ENDIF}
If you use dcc32.exe, all warnings will be shown, always. (This is another reason why I use build scripts for all my projects.)
I am still using D6 for some projects and if I do a full build then all hints and warnings are displayed/re-displayed. For syntax check or compile only changed unit messages are displayed.
You have something else wrong or damaged somewhere. Try deleting the project .dsm and the .dof files (they will be rebuilt) the .dof file contains the warnings and hints flags.

Resources