1
0

c_decl.h 811 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * c_decl.h
  3. *
  4. * a simple set of macros to ease declaration of C interfaces.
  5. */
  6. /**
  7. \ingroup lub
  8. \defgroup lub_c_decl C linkage macros
  9. @{
  10. These two macros are used to simplify the declaration of C-linkage code.
  11. Rather than worry about preprocessor directives similar to
  12. \code
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. int foobar(void);
  17. #ifdef __cplusplus
  18. }
  19. #endif
  20. \endcode
  21. you simply need to use the _BEGIN_C_DECL and _END_C_DECL macros instead.
  22. \code
  23. #include "lub/c_decl.h"
  24. _BEGIN_C_DECL
  25. int foobar(void);
  26. _END_C_DECL
  27. \endcode
  28. */
  29. #ifndef _lub_c_decl_h
  30. #define _lub_c_decl_h
  31. #ifdef __cplusplus
  32. #define _BEGIN_C_DECL extern "C" {
  33. #define _END_C_DECL }
  34. #else /* not __cplusplus */
  35. #define _BEGIN_C_DECL
  36. #define _END_C_DECL
  37. #endif /* not __cplusplus */
  38. /** @} */
  39. #endif /* _lub_c_decl_h */