cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: compiling with C++ compiler

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 4 Feb 2011 00:07:06 +0100 (CET)

On Thu, 3 Feb 2011, Prashant R wrote:

> I know that this library was intended to compile in C however I have certain
> limitations where this needs to be compiled using a C++ compiler .

C is not C++ and vice versa, though.

> new_rb = realloc(in->buffer, new_size);

> I am wondering if there is any harm in doing the explicit cast in code so
> that C++ compilers will readily compile.

I don't think so, unless there's a rare special case somewhere.

The harm is that you make the code uglier and harder to follow with a typecast
that isn't necessary in C.

> I understand that this might be a huge change for the library and if this
> has been the way for historical reasons !

It's not a change for us, it's a change for you. I want libcurl to compile
warning-free with very picky C compilers but I have no desire to have it
compile with C++ compilers.

> I guess I am being picky and in no way am trying to disregard the value of
> this library .

I don't think that is being picky, I think it is getting yourself a lot of
work for very little value. I think putting that effort into convincing your
surrounding that C code should be compile with a C compiler is a better idea.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-02-04