[FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

Soft Works softworkz at hotmail.com
Sun Jun 19 01:48:44 EEST 2022



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Martin Storsjö
> Sent: Sunday, June 19, 2022 12:24 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove
> MAX_PATH limit and use UTF-8 version of getenv()
> 
> On Fri, 17 Jun 2022, Nil Admirari wrote:
> 
> > 1. getenv() is replaced with getenv_utf8() across libavformat.
> > 2. New versions of AviSynth+ are now called with UTF-8 filenames.
> > 3. Old versions of AviSynth are still using ANSI strings,
> >   but MAX_PATH limit on filename is removed.
> > ---
> > libavformat/avisynth.c    | 39 +++++++++++++++++++++++++++---------
> ---
> > libavformat/http.c        | 20 +++++++++++++-------
> > libavformat/ipfsgateway.c | 35 +++++++++++++++++++++++------------
> > libavformat/tls.c         | 11 +++++++++--
> > 4 files changed, 72 insertions(+), 33 deletions(-)
> >
> > diff --git a/libavformat/http.c b/libavformat/http.c
> > index c8f3f4b6a3..d90117e422 100644
> > --- a/libavformat/http.c
> > +++ b/libavformat/http.c
> > @@ -29,6 +29,7 @@
> > #include "libavutil/avassert.h"
> > #include "libavutil/avstring.h"
> > #include "libavutil/bprint.h"
> > +#include "libavutil/getenv_utf8.h"
> > #include "libavutil/opt.h"
> > #include "libavutil/time.h"
> > #include "libavutil/parseutils.h"
> 
> This actually causes some surprise breakage in MSVC builds. Here,
> getenv_utf8.h includes windows.h. If including windows.h and winsock2
> headers in the same file, the winsock2 headers must be included
> before.
> 
> I fixed it locally by moving this new include down, with a comment
> like
> this:
> 
> /* This header can include <windows.h>. That header has to be
> included after
>   * winsock2 headers (included by network.h and os_support.h above).
> */

This is the recommended way:


#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <winsock2.h>


<Quote>
The Winsock2.h header file internally includes core elements from the Windows.h header file, so there is not usually an #include line for the Windows.h header file in Winsock applications. If an #include line is needed for the Windows.h header file, this should be preceded with the #define WIN32_LEAN_AND_MEAN macro. For historical reasons, the Windows.h header defaults to including the Winsock.h header file for Windows Sockets 1.1. The declarations in the Winsock.h header file will conflict with the declarations in the Winsock2.h header file required by Windows Sockets 2. The WIN32_LEAN_AND_MEAN macro prevents the Winsock.h from being included by the Windows.h header.
</Quote>

References:

https://docs.microsoft.com/en-us/windows/win32/winsock/include-files-2
https://docs.microsoft.com/en-us/windows/win32/winsock/creating-a-basic-winsock-application

Best regards,
softworkz



More information about the ffmpeg-devel mailing list