cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Problem with strdup

From: Eric VERGNAUD <eric.vergnaud_at_jlynx.com>
Date: Sun, 19 Dec 2004 12:36:41 +0100

le 19/12/04 6:29, David M. Bennett à d.b_at_pfxcorp.com a écrit :

> If I may insert by 2d worth---
>
> The C/C++ standards do NOT define what will happen if you link together a
> random mixture of libs from C/C++ and from different vendors. You can't rely
> on it, and you shouldn't (if you value the stability of your product).
>
> My scene is Windows (not *nix or Apple), but the same applies. I would never
> consider linking together libs using C/C++ conventions from (say)
> Microsoft/Borland/gcc.
>
> It is marginally safe to link C with C++, but only if you have total control
> over all source, and you're prepared to track down and manage the inevitable
> incompatibilities. If isn't strdup(), it will get in your printf(), fopen()
> or somewhere else. Often the only solution is to convert the C code into C++
> code -- I've been there.
>
> Mixing different vendors is just as bad. Lots of stuff works; some doesn't;
> don't risk it.
>
> Solution: use final-linkage techniques. On Windows that usually means
> building DLLs or COM objects. Different strokes for different folks.
>
> Yes, it would be helpful if product suppliers delivered source code that
> could be COMPILED as either C or C++, but expecting them to manage C++
> problems in C code is not reasonable.
>
> Happy to listen to other viewpoints, but that's the way I see it.
>

In my case, I don't think this is related to mixing C/C++, which I've been
doing fr years with absolutely no problem, but rather to mixing compilers.

I agree it's preferable not to do that, but the problem is it can't always
be avoided. Many open source libraries are compiled using gcc and won't
compile (on MacOS) with other compilers. One of the reasons is that on MacOS
gcc provides builtin glue code for many c functions which is not available
with other compilers.

And after all, apps compiled using Metrowerks work perfectly with the system
libraries provided by Apple, which are compiled using gcc.

So I guess the main issue is the stdlib itself, and the fact Metrowerks is
providing its own rather than using Apple's.

-------------------------------
Eric VERGNAUD - JLynx Software
Cutting-edge technologies and
services for software companies
web: http://www.jlynx.com
-------------------------------
Received on 2004-12-19