The following code in Delphi 2007 gives me the warning
W1047 Unsafe code '@ operator'
in the line that passes @ThreadNameInfo to RaiseException:
procedure SetThreadName(const _Name: AnsiString);
var
ThreadNameInfo: TThreadNameInfo;
begin
ThreadNameInfo.FType := $1000;
ThreadNameInfo.FName := PAnsiChar(_Name);
ThreadNameInfo.FThreadID := $FFFFFFFF;
ThreadNameInfo.FFlags := 0;
try
RaiseException($406D1388, 0, SizeOf(ThreadNameInfo) div SizeOf(LongWord),
@ThreadNameInfo); // --> Here
except
// ignore
end;
end;
Apart from disabling the compiler warning for "unsafe code", is there any other way to get rid of this warning? Does this warning even make sense any more, since Delphi no longer supports dotNET?
I tried to explicitly typecast the parameter to PDWord (the declared type of the last parameter), which didn't change anything.
This warning is intended for use with code that is to be compiled by the .net compiler. If you are not using the Delphi .net compiler you can, and should, suppress that particular warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With