I’m compiling a c++ dll from a reasonably well vetted library (zeromq), and consuming it in my own Delphi bindings. I’m currently hitting an unexpected behavior in the C++ code, and don’t have the background to debug it well. The ultimate responsibility for the bug is probably in my Delphi code, but I need to understand the C++ better to know what I did wrong.
The problem code looks like this (simplified)
if (*mySize_tObject == sizeof (uint64_t)) {
return 0;//We never reach this code.
}
*mySize_tObject is passed in as a size_t. In my Delphi bindings, it is a Cardinal with a value of 8.
I’ve tried playing around with the C++ outputs to narrow down what might be happening, and gotten these results:
return *mySize_tObject;//8
return sizeof (uint64_t);//8
return *mySize_tObject + sizeof (uint64_t);//16
if(*mySize_tObject > sizeof (uint64_t)) return 1;//1
if(*mySize_tObject < sizeof (uint64_t)) return 1;//not 1
So I’m getting back, essentially, 8>8. Since I know that isn’t true (citation needed), I’m left thinking that one of these values is secretly a float like 8.000001 and I’m only seeing truncated results.
I would also consider tips for live debugging a .dll if this doesn’t make any sense to people that know c++.
2