[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
C++ Usage Issues - Problems, Solutions, and Suggestions
- Date: Fri, 22 Jun 2007 07:15:00 -0400
- From: hoan at tidalstream.com (Hoan Hoang)
- Subject: C++ Usage Issues - Problems, Solutions, and Suggestions
I think the standard way for C prototypes to compile both in C or C++
would be as bellow because C compiler would not understand extern "C".
#ifdef __cplusplus
extern "C" {
#endif
/* Prototypes here */
#ifdef __cplusplus
}
#endif
__cplusplus is a standard macro defined in all C++ compiler so you don't
need to worry about defining macroes when porting to other platforms.
> 2. Some header files are not quite ready for C++ compatibility.
> Specifically, this exercise found one, rtems/rtems_bsdnet.h, that does
> not include appropriate measures. Having to type this:
>
> extern "C" {
> #include <rtems/rtems_bsdnet.h>
> }
>
> is ugly and just plain wrong. This header, and others like it, should
> be modified to use the _BEGIN_STD_C and _END_STD_C appropriately to
> encapsulate definitions that the C++ compiler will otherwise mangle.
> Using these macros are better then simply extern "C" { } approach too,
> because they seem to handle the std namespace correctly.
>
>