C99 _Complex and C++ complex<> interoperability.

Howard Hinnant hhinnant@apple.com
Thu Feb 22 21:41:00 GMT 2007


On Feb 22, 2007, at 1:25 PM, Smith-Rowland, Edward M wrote:

> My questions are:
>  Is this behavior standard or is this a gcc extension?
>  If this is a gcc extension where is it documented?
>
> Also, if this behavior is nonstandard is anyone thinking about
> standardizing it?
> Finally, the circle would be complete if we could assign from
> std::complex to _Complex.
> Any ideas?  There is a private functions that return _Complex from
> std::complex.

Fwiw here are some relevant links:

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#387

The above link is a C++ committee library working group defect report  
on this subject.  It is in an open state meaning that no decision has  
been made.

Below is a link to a paper which further discusses (really just  
summarizes) the issue:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1589.html

In a nutshell, there is support on the C++ committee for making the C+ 
+ and C99 complex types layout compatible.  I'm not aware of support  
for making them API compatible.  Currently C++ will not parse the  
syntax for C99 complex types and I know of know proposal to do so.   
However if the complex types were layout compatible one could link C99  
and C++ sources and have them refer to the very same complex data  
structures, even passing them back and forth (just referenced with  
different syntax in the different translation units).

-Howard



More information about the Libstdc++ mailing list