[Ffmpeg-devel] [PATCH] Add allformats.h include file to move *_init() functions and other
Rich Felker
dalias
Tue Jul 4 20:57:54 CEST 2006
On Sat, Jul 01, 2006 at 09:02:15AM +0200, Steve Lhomme wrote:
> Rich Felker wrote:
> >On Fri, Jun 30, 2006 at 09:40:25AM +0200, Steve Lhomme wrote:
> >>Rich Felker wrote:
> >>>On Thu, Jun 29, 2006 at 10:37:28AM -0700, Mike Melanson wrote:
> >>>>Steve Lhomme wrote:
> >>>>>Is there a C compiler that fails on extern "C" ? At least among the
> >>>>>one(s) supported by FFMPEG.
> >>>>It's a moot issue since the extern is surrounded by "#ifdef
> >>>>__cplusplus".
> >>>My point is that C++ code does not belong in a C project, even under
> >>>#ifdef!!! If a C++ project is doing interlanguage linking to C code,
> >>>then it should put the C headers inside its own 'extern "C"' block to
> >>>make this clear.
> >>I agree. Except that libavcodec/libavformat are libraries. And the
> >>library user (ie a programmer) shouldn't have to wonder if the C calling
> >>convention or the C++ one has to be applied. Unless he has to check the
> >>original source to see what is the original programming language.
> >
> >Nonsense. There's no way you can use a library without knowing its
> >language.
>
> Precisely to tell the library user what calling convention has to be
> used. Imagine a library that has both C and C++ code (a C++ API with
> some C callbacks for example). Is it up to the library user to know what
> is the format of the C parts ? No. It's up to the library to tell what
> is what.
In this case the language of the library is C++, and as such, if it
uses C calling convention for part of the API, it must use extern "C".
On the other hand, if the language of the library is C, it should have
no artifacts of C++ whatsoever.
> BTW, I don't have Linux loaded, but in MinGW I can see
...
> 280 standard
> headers
No such thing. There are 84 standard headers.
> that have the '#ifdef _cplusplus extern "C"' thingy...
Yes this is because C++ also specifies the existence of these headers,
and rather than include a second set of headers (or wrapper headers)
for C++ they choose to include the nasty C++ cruft in the C headers.
My implementation is different. It has no such crap, and if you want
to use the headers with C++ you must provide wrappers.
> >Anyway the language for any legitimate library is C.
>
> Shouldn't there be just one language and one OS anyway ?
One programming language, yes, C. As for OS it depends on what you
mean by one OS. One implementation, no. One interface, yes.
Rich
More information about the ffmpeg-devel
mailing list