[PATCH] talloc: Add ifdef'd extern "C" to ease use in C++ projects.
Matthias Dieter Wallnöfer
mdw at samba.org
Tue Jun 29 06:40:05 MDT 2010
Tridge,
what do you think about this patch (talloc compatibility with C++)? I
think it could really be worth to apply it.
Matthias
Kenneth Graunke wrote:
> 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
>
More information about the samba-technical
mailing list