madExcept causes compilation errors in Delphi 10.2

delphi package - automated exception handling
Post Reply
tkunicki
Posts: 3
Joined: Fri Feb 19, 2016 8:41 pm

madExcept causes compilation errors in Delphi 10.2

Post by tkunicki »

We treat uninitialized variable warning as an error which makes impossible madexcept to compile under Win64 because of invalid way of casting used which is triggering warnings now

NativeUInt(sh) := NativeUInt(mh) + sizeOf(TImageNtHeaders64)

Instead of casting left side you should cast right side to pointer this will not trigger compiler warning.

sh := Pointer(mh + sizeOf(TImageNtHeaders64))

It does not have to be typed pointer. The problem appears in madExcept.pas and in madMapFile.pas
pfennig59
Posts: 4
Joined: Sat Jun 03, 2017 10:40 am

Re: madExcept causes compilation errors in Delphi 10.2

Post by pfennig59 »

We ran into the same problem and I too would prefer to do the casting only on the right side.

Although, it should be
sh := Pointer(NativeUInt(mh) + sizeOf(TImageNtHeaders64)) ,

otherwise you'll get an error E2015: Operator not applicable to this operand type

It also affects unit madTools.pas from the madBasic package.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept causes compilation errors in Delphi 10.2

Post by madshi »

Somewhat strange. These warnings don't seem to show up if I batch compile madExcept. I'm wondering why you're recompiling madExcept.pas, anyway? Why not simply using the precompiled DCUs I'm shipping with madExcept.

Anyway, I'll have a look at these warnigs. Although I have to say, they don't make sense to me. IMHO the code "NativeUInt(sh) := NativeUInt(mh) + sizeOf(TImageNtHeaders64)" is perfectly fine!
Post Reply