Re: extern "C" in library header
- From: rlb@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos)
- Date: Fri, 29 Jun 2007 09:21:28 GMT
William Pursell <bill.pursell@xxxxxxxxx> wrote:
#ifndef FOO_HDR
#define FOO_HDR 1
#ifdef __cplusplus
extern "C" {
namespace foo {
#endif /* __cplusplus */
int foo_function(int x);
#ifdef __cplusplus
int function( int x ) { return foo_function( x ); }
} /* namespace foo */
} /* extern "C" */
#endif /* __cplusplus */
#endif /* FOO_HDR */
Bah.
The questions are:
1) Given that libfoo is a C library, and that foo.h is a
C header file, I find the above code somewhat
hideous.
That doesn't even begin to describe it.
Perhaps the best solution would be to have two headers, a foo.h for C,
and a foo.h++ for c++. A slight bit more work, but probably worth it.
Richard
.
- Follow-Ups:
- Re: extern "C" in library header
- From: Keith Thompson
- Re: extern "C" in library header
- References:
- extern "C" in library header
- From: William Pursell
- extern "C" in library header
- Prev by Date: Re: change standard deviation of normal or Gaussian distribution (faq 13.20)
- Next by Date: Re: when to use ; and when to use ,
- Previous by thread: Re: extern "C" in library header
- Next by thread: Re: extern "C" in library header
- Index(es):
Relevant Pages
|