[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Re: C++ Gurus - Is C++ a good choice for public API(s)??? Are there clean ways to solve known problems there?

Nick Keighley

6/1/2009 9:03:00 AM

Posted to comp.programming in case they have any ideas on clean
public interfaces

On 31 May, 22:19, ariji...@gmail.com wrote:

> I needed to build up a public API for an application at hand.
>
> The data I am modelling maps very well to object oriented design, so I
> am little inclined towards a C++ public API (i.e. my deliverables
> would be a <xyz>.hpp file which will have a bunch of pure virtual
> functions forming the interface and a lib<xyz>.so which will basically
> contain the implementation for those interfaces).

as another poster pointed out your functions aren't virtual.
Do your APIs contain classes?


> But, I can think of 2 problems there:
> 1) How do I guarantee that my shared library will work well with the
> version of the C++ library/compiler my customer/user is having?
> Issue in detail: I mean, I compile my shared library with version 'X'
> of a Std CPP compiler and customer tries to use with version 'Y' of
> StdCPP compiler. And then, if 'X' and 'Y' versions of CPP compiler are
> not compatible, then we get into trouble. We have hit this several
> times with different gcc versions. Just wondering, what is the best/
> cleanest way to solve/get-around this problem?

it's probably insoluable in *any* language. Might it be better
to define an interface in terms of simple structures that are defined
as streams of bytes. Then provide some sort of RPC interface.

You might then look at ASN.1 or XML.

You loose the tight coupling between your application and the client
but gain the huge advantage of loosing the tight...


<snip>

--
Nick Keighley