diff mbox

[FFmpeg-devel] avutil/error: hidden macro av_err2str for C++

Message ID 20180517044626.4554-1-quinkblack@foxmail.com
State New
Headers show

Commit Message

zhilizhao May 17, 2018, 4:46 a.m. UTC
---
 libavutil/error.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Rostislav Pehlivanov May 17, 2018, 4:50 a.m. UTC | #1
On 17 May 2018 at 05:46, Zhao Zhili <quinkblack@foxmail.com> wrote:

> ---
>  libavutil/error.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavutil/error.h b/libavutil/error.h
> index 71df4da..8a35fef 100644
> --- a/libavutil/error.h
> +++ b/libavutil/error.h
> @@ -116,8 +116,10 @@ static inline char *av_make_error_string(char
> *errbuf, size_t errbuf_size, int e
>   * Convenience macro, the return value should be used only directly in
>   * function arguments but never stand-alone.
>   */
> +#ifndef __cplusplus
>  #define av_err2str(errnum) \
>      av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0},
> AV_ERROR_MAX_STRING_SIZE, errnum)
> +#endif
>
>  /**
>   * @}
> --
> 2.9.5
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

NAK
Chopping off parts of the API because it doesn't play well when included in
a different language is not a good idea.
Just do #undef av_make_error_string in your own code.
wm4 May 17, 2018, 8:22 a.m. UTC | #2
On Thu, 17 May 2018 05:50:55 +0100
Rostislav Pehlivanov <atomnuker@gmail.com> wrote:

> On 17 May 2018 at 05:46, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> > ---
> >  libavutil/error.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libavutil/error.h b/libavutil/error.h
> > index 71df4da..8a35fef 100644
> > --- a/libavutil/error.h
> > +++ b/libavutil/error.h
> > @@ -116,8 +116,10 @@ static inline char *av_make_error_string(char
> > *errbuf, size_t errbuf_size, int e
> >   * Convenience macro, the return value should be used only directly in
> >   * function arguments but never stand-alone.
> >   */
> > +#ifndef __cplusplus
> >  #define av_err2str(errnum) \
> >      av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0},
> > AV_ERROR_MAX_STRING_SIZE, errnum)
> > +#endif
> >
> >  /**
> >   * @}
> > --
> > 2.9.5
> >
> >
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >  
> 
> NAK
> Chopping off parts of the API because it doesn't play well when included in
> a different language is not a good idea.
> Just do #undef av_make_error_string in your own code.

+1, I don't want a __cplusplus mess in the headers. We can document
them as C99 only, though.
Timo Rothenpieler May 17, 2018, 10 a.m. UTC | #3
On 17.05.2018 06:46, Zhao Zhili wrote:
> ---
>  libavutil/error.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavutil/error.h b/libavutil/error.h
> index 71df4da..8a35fef 100644
> --- a/libavutil/error.h
> +++ b/libavutil/error.h
> @@ -116,8 +116,10 @@ static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int e
>   * Convenience macro, the return value should be used only directly in
>   * function arguments but never stand-alone.
>   */
> +#ifndef __cplusplus
>  #define av_err2str(errnum) \
>      av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
> +#endif

It's a macro, as long as you don't call it, it should never hit the
compiler.
So this will only change the error as now the macro won't be known anymore.
diff mbox

Patch

diff --git a/libavutil/error.h b/libavutil/error.h
index 71df4da..8a35fef 100644
--- a/libavutil/error.h
+++ b/libavutil/error.h
@@ -116,8 +116,10 @@  static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int e
  * Convenience macro, the return value should be used only directly in
  * function arguments but never stand-alone.
  */
+#ifndef __cplusplus
 #define av_err2str(errnum) \
     av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
+#endif
 
 /**
  * @}