D and C APIs

bachmeier via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 10:23:47 PST 2016


On Tuesday, 12 January 2016 at 16:21:40 UTC, Atla Neves wrote:

> In C/C++, a change to the headers causes a recompilation which 
> will fail if there are API changes. From any other language, 
> it'll compile, link, and fail at runtime (unless the symbols 
> change name). If you're lucky in an obvious way.
>
> Atila

It's true that working directly with the upstream header file 
will catch errors that are not caught at compile time in other 
languages, but that's only an issue if you're not testing the 
calls you're making to the API. A couple of simple examples where 
replacing the old header with the new is not a good substitute 
for testing in the presence of arbitrary changes:

1. There's a change in the return value from 0=success to 
0=failure. Then your program every so often dies with a segfault 
somewhere else, and it takes two days to track down the problem.

2. The function body stays the same but the signature changes 
from int foo(int x, int y) to int foo(int y, int x). Suddenly 
you're dividing by zero with previously working code.



More information about the Digitalmars-d mailing list