[PATCH] talloc: Add ifdef'd extern "C" to ease use in C++ projects.

Kenneth Graunke kenneth at whitecape.org
Fri Jun 25 22:22:55 MDT 2010


Currently, if one wishes to use talloc in a C++ program, one has to write:

extern "C" {
#include <talloc.h>
}

This patch takes care of that in talloc.h so C++ programmers can simply write:
#include <talloc.h>

This is much nicer, especially since forgetting the extern results in obscure
linker errors.  C programs should be unaffected by this patch.

---
 lib/talloc/talloc.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index c59fd35..da9b1f8 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -29,6 +29,10 @@
 #include <stdio.h>
 #include <stdarg.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  * @defgroup talloc The talloc API
  *
@@ -1681,4 +1685,8 @@ void talloc_set_log_stderr(void);
 #define TALLOC_MAX_DEPTH 10000
 #endif
 
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
+
 #endif
-- 
1.7.1



More information about the samba-technical mailing list