3 ms·
I was interested in the remarks about Windows perverted stackframes. I once had some MS C code that called some 3rd-party library function. This was a long tim
by denton-scratch 4y ago
I was interested in the remarks about Windows perverted stackframes.
I once had some MS C code that called some 3rd-party library function. This was a long time ago, I don't remember all the details! But roughly, the code did a comparison, called this function, then made a jump conditional on the result of the comparison. But the condition wasn't being evaluated correctly.
It turned out that the library was built using a Borland compiler; my code was Microsoft C. The calling conventions differed; Borland expected the caller to save the flag register on the stack before calling, and restore it on returning; Microsoft expected the called function to do this. As a result, the flags that had been set before the function call were junk after it returned.
The way that Borland did it was the "convention" - as far as I'm aware, Microsoft stood alone on this. I formed the belief that Microsoft was doing things the way it did in order to deliberately make Microsoft C code incompatible with libraries built with 3rd-party compilers.