Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #8479

Re: Is there any software porting C++ to C?

From Nobody <nobody@nowhere.com>
Subject Re: Is there any software porting C++ to C?
Date 2011-08-04 21:54 +0100
Message-Id <pan.2011.08.04.20.54.25.130000@nowhere.com>
Newsgroups comp.lang.c++
References <xxsZp.48094$T85.36355@newsfe19.ams2> <49572b2b-49fc-4cd7-9d97-c6891c20d2ef@t38g2000prj.googlegroups.com> <4e3ad745$0$4151$6e1ede2f@read.cnntp.org> <j1ema2$feg$1@dont-email.me>
Organization Zen Internet

Show all headers | View raw


On Thu, 04 Aug 2011 13:53:06 -0400, Victor Bazarov wrote:

>>> If the C++ code uses exceptions, you're in a world of pain. It's
>>> borderline impossible for this to be automated. C++ exceptions are the
>>> one C++ feature that does not map nicely onto C.
>>
>> Pardon my ignorance (I've never written a C++ compiler), but what's the
>> problem with exceptions? I'd imagine them to be rather straightforward
>> to implement using setjmp()/longjmp().
> 
> I am thinking the complexity is in "stack unwinding", due to the need to 
> destruct all local objects still "alive" between the 'try' and 'throw'. 
>   IOW, it's not as simple as just transferring control from one part of 
> the code to the other.  C doesn't have the "stack unwinding" need, you see.

Right. But that's more of an issue with destructors than exceptions per
se. You still need to call destructors on leaving scope, however that
occurs.

The interaction between exceptions and destructors means that you would
need a handler (setjmp) for every block which creates one or more
automatic variables having a destructor, not just for every try/catch.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is there any software porting C++ to C? "crea" <no@invalid.com> - 2011-08-01 08:25 +0100
  Re: Is there any software porting C++ to C? Ian Collins <ian-news@hotmail.com> - 2011-08-01 19:42 +1200
    Re: Is there any software porting C++ to C? "crea" <no@invalid.com> - 2011-08-01 08:47 +0100
      Re: Is there any software porting C++ to C? "Bo Persson" <bop@gmb.dk> - 2011-08-01 11:21 +0200
        Re: Is there any software porting C++ to C? "crea" <no@invalid.com> - 2011-08-01 10:26 +0100
      Re: Is there any software porting C++ to C? Ian Collins <ian-news@hotmail.com> - 2011-08-01 21:26 +1200
        Re: Is there any software porting C++ to C? "crea" <no@invalid.com> - 2011-08-01 11:16 +0100
          Re: Is there any software porting C++ to C? Robert Wessel <robertwessel2@yahoo.com> - 2011-08-01 11:59 -0500
            Re: Is there any software porting C++ to C? BGB <cr88192@hotmail.com> - 2011-08-01 14:18 -0700
            Re: Is there any software porting C++ to C? James Kanze <james.kanze@gmail.com> - 2011-08-07 11:39 -0700
  Re: Is there any software porting C++ to C? Juha Nieminen <nospam@thanks.invalid> - 2011-08-01 08:48 +0000
    Re: Is there any software porting C++ to C? "crea" <no@invalid.com> - 2011-08-01 10:29 +0100
    Re: Is there any software porting C++ to C? "Waldek M." <wm@localhost.localdomain> - 2011-08-04 21:54 +0200
  Re: Is there any software porting C++ to C? Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-08-01 11:29 +0200
  Re: Is there any software porting C++ to C? Joshua Maurice <joshuamaurice@gmail.com> - 2011-08-02 14:45 -0700
    Re: Is there any software porting C++ to C? Philipp Klaus Krause <pkk@spth.de> - 2011-08-04 19:30 +0200
      Re: Is there any software porting C++ to C? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-04 13:53 -0400
        Re: Is there any software porting C++ to C? jt@toerring.de (Jens Thoms Toerring) - 2011-08-04 20:38 +0000
        Re: Is there any software porting C++ to C? Nobody <nobody@nowhere.com> - 2011-08-04 21:54 +0100
      Re: Is there any software porting C++ to C? BGB <cr88192@hotmail.com> - 2011-08-04 15:40 -0700
  Re: Is there any software porting C++ to C? Uwe Dolinsky <uwe@codeplay.com> - 2011-08-03 07:34 -0700

csiph-web