[ 
https://issues.apache.org/jira/browse/STDCXX-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563384#action_12563384
 ] 

Martin Sebor commented on STDCXX-710:
-------------------------------------

In principle, I suppose a patch along these lines might be okay, even though it 
assumes a C99 compiler (otherwise, to compile in C89 mode, we would also need 
to change the C++ comments to C style). I do wonder if the attached patch deals 
with all such cases in our C compatibility headers, including the overloads C++ 
adds to some functions (such as {{bsearch()}} and {{qsort()}} in 
{{<stdlib.h>}}).

That said, I'm not at all sure it makes sense to be compiling C code with the 
C++ Standard Library headers in the search path. If Boost wants to compile C 
code they should be using a C compiler, including the C compiler's options, not 
a mishmash of C and C++ code and options.

Incidentally, we normally try to avoid preprocessor directives in code by 
hiding them behind macros defined in 
[rw/_defs.h|http://svn.apache.org/repos/asf/stdcxx/trunk/include/rw/_defs.h] so 
if we should decide to accept a patch for this I would suggest replacing the 
#ifdefs in it with something like below. But first I'd like to know how 
pervasive the Boost failures are and if there might be a way to patch Boost to 
eliminate the errors.

{noformat}
#ifdef __cplusplus
#  define _RWSTD_EXTERN_C_BEGIN   extern "C" {
#  define _RWSTD_EXTERN_C_END     }
#else
#  define _RWSTD_EXTERN_C_BEGIN   /* empty */
#  define _RWSTD_EXTERN_C_END     /* empty */
#endif
{noformat}


> C code fails to compile with stdcxx
> -----------------------------------
>
>                 Key: STDCXX-710
>                 URL: https://issues.apache.org/jira/browse/STDCXX-710
>             Project: C++ Standard Library
>          Issue Type: Improvement
>    Affects Versions: 4.1.2, 4.1.3, 4.2.0
>         Environment: All
>            Reporter: Farid Zaripov
>            Assignee: Farid Zaripov
>            Priority: Trivial
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-710.patch
>
>   Original Estimate: 1h
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> The boost regression tests contains some .c files, which are failed to 
> compile with stdcxx.
> The example:
> ----------------------------------
> #include <assert.h>
> #include <ctype.h>
> #include <errno.h>
> #include <float.h>
> #include <limits.h>
> #include <locale.h>
> #include <math.h>
> #include <setjmp.h>
> #include <signal.h>
> #include <stdarg.h>
> #include <stddef.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <time.h>
> #include <wchar.h>
> #include <wctype.h>
> int main ()
> {
>     return 0;
> }
> ----------------------------------
>   The build log on MSVC:
> ----------------------------------
> test.cpp
> D:\stdcxx\stdcxx-4.2.x\include\rw\_defs.h(1142) : error C2061: syntax error : 
> identifier '__rw'
> D:\stdcxx\stdcxx-4.2.x\include\rw\_defs.h(1142) : error C2059: syntax error : 
> ';'
> D:\stdcxx\stdcxx-4.2.x\include\rw\_defs.h(1142) : error C2449: found '{' at 
> file scope (missing function header?)
> D:\stdcxx\stdcxx-4.2.x\include\rw\_defs.h(1163) : error C2059: syntax error : 
> '}'
> ----------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to