[c++-pthreads] C++ and posix threads

Ted Baker baker at cs.fsu.edu
Tue Dec 23 16:03:14 UTC 2003


Am I missing something here?

How do you propose to modify read() to throw an exception and
still have backwards compatability with applications that expect
read() to always return (more specifically, to return -1 if it
fails)?

It seems to me that the only way you could do this is to
define a function with a new name, e.g., read_with_exception()
in your binding.  Otherwise, the linker will not be able to
tell the difference between your exception-throwing read()
and the normal C one.  (OK, you might try playing macro games
with renaming read() subject to a conditional compilation flag
for C++ programs, but: (1) that is very error prone; (2)
it would break existing C++ programs that are using calls
to C-library functions like read().

--Ted

On Mon, Dec 22, 2003 at 02:18:18PM -0800, Mark Mitchell wrote:
> On Mon, 2003-12-22 at 13:57, Ted Baker wrote:
> > > (c) it is OK to consider slightly broader modifications to the existing
> > > C interfaces for C++ (such as modifying "read()" to throw an exception),
> > > but it should still be possible to recompile C programs as C++ programs
> > > and get reasonable behavior.
> > 
> > I don't think you will be able to get buy-in from vendors or
> > users of C if you require changes to the POSIX C libraries that
> > would change the behavior of any existing C application that
> > conforms to the current Open Group Unix or the IEEE POSIX
> > standards.
> 
> I agree -- but I did not say that.  I said:
> 
>   it is OK to consider slightly broader modifications to the
>   existing C interfaces for C++
> 
> There's no inherent reason why a vendor would refuse to make a change to
> the interfaces in some new mode -- so long as the
> backwards-compatibility requirement you mention were preserved.
> 
> -- 
> Mark Mitchell <mark at codesourcery.com>
> CodeSourcery, LLC



More information about the c++-pthreads mailing list