How to get rid of "W1047 Unsafe code" @operator "in this RaiseExeption call

The following code in Delphi 2007 gives me a warning

W1047 Insecure code '@operator'

on 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;

Besides disabling the compiler warning for β€œunsafe code,” is there any other way to get rid of this warning? Does this warning even make more sense since Delphi no longer supports dotNET?

I tried to explicitly specify the parameter in PDWord (the declared type of the last parameter), which did not change anything.

+4
source share
1 answer

, .net. Delphi.net, .

+7

Source: https://habr.com/ru/post/1675132/


All Articles