Ian Collins wrote:
> jacob navia wrote:
>> Ian Collins wrote:
>>> jacob navia wrote:
>> [snip]
>>>> This is not true. Most C++ compilers support C and will allow C and
>>>> C++ to coexist peacefully.
>>> They do, provided you use C linkage functions (extern "C" in the C++
>>> world). Exceptions are alien to C, so you simply can't propagate
>>> exceptions through a C function.
>>>
>> Yes you can. I have done this under gcc and msvc, and I think
>> all C++ compilers will generate compatible code.
>>
> More by luck than anything else. The mechanics may work, but it's a
> very dangerous thing to do because the C code will not be exception
> aware, let alone safe.
>
Who cares?
C doesn't have to know any exceptions!
The throw will pass through the C stack part until it finds a catch.
Most compilers generate a set of tables describing the stack layout
of each function so that the throw mechanism can walk the stack.
If you compile with the same compiler, those tables get generated for
the C code and you are in business.
> Like all things undefined, the next compiler release could break your code.
>
I said that explicitely in my FIRST message. You need to keep
compatible versions of everything:
o The tables generated by the compiler
o The throw run time mechanism
>>>> Problems arise when you mix different
>>>> compilers and versions or you want to generate code dynamically.
>>>>
>>> A problem in C++, but in C? The C ABI is determined by the platform,
>>> not the compiler (at least in the Linux/Unix world). If a compiler used
>>> a different ABI, how could it link to system libraries?
>>>
>> If you use different compilers, the throw machinery ill be different
>> and passing throws will just not work.
>>
> Double check my post, I said "The C ABI is determined by the platform".
> C doesn't have throw machinery.
>
You just do not know what the issue here is. Reread the OP
message, and my answers. Obviously C doesn't have and doesn't
need any throw machinery. That is not the issue here.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32