Mega Search
23.2 Million


Sign Up

Make a donation  
Is (see inside) a good idea to do to a public API  
News Group: comp.lang.c++

Hi,

I know this is off-topic because it's C-specific, but comp.lang.c discussion level seems to low, but comp.lang.c.moderated is all but dead and comp.std.c seems just as inappropriate. Please bear with me, here goes...

I have a public API like this:

extern "C" rettype api(param* p);

Now... This really is a mistake, it's an input parameter so it should have been:

extern "C" rettype api(const param* p);

Question: is this safe to do given that this is a public API and I don't control client code? Any downsides?

(To be frank: I am annoyed by GCC warnings in some old code, it's about char* and api("toto")).

TIA,

Goran.

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 28-Aug-2014, at 4:26 AM EST
From: m
 
Re: Is (see inside) a good idea to do to a public API  
News Group: comp.lang.c++
On Thu, 28 Aug 2014 04:26:34 -0700, goran.pusic wrote:

> Hi,
> 
> I know this is off-topic because it's C-specific, but comp.lang.c
> discussion level seems to low, but comp.lang.c.moderated is all but dead
> and comp.std.c seems just as inappropriate. Please bear with me, here
> goes...
> 
> I have a public API like this:
> 
> extern "C" rettype api(param* p);
> 
> Now... This really is a mistake, it's an input parameter so it should
> have been:
> 
> extern "C" rettype api(const param* p);
> 
> Question: is this safe to do given that this is a public API and I don't
> control client code? Any downsides?
> 
> (To be frank: I am annoyed by GCC warnings in some old code, it's about
> char* and api("toto")).

Yes, it is safe, and should have no downsides as fa as I know.

M4

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 28-Aug-2014, at 1:58 PM EST
From: Martijn Lievaart