Re: [FFmpeg-devel] [FFmpeg-cvslog] lavf/os_support.h: Fix for unicode filenames on windows.

2016-06-13 Thread Ricardo Constantino
This patch seems to break build with decklink in MinGW:

In file included from
C:/builds/ab-full/build/ffmpeg-git/libavformat/internal.h:28:0,
 from
C:/builds/ab-full/build/ffmpeg-git/libavdevice/decklink_common.cpp:34:
C:/builds/ab-full/build/ffmpeg-git/libavformat/os_support.h: In
function 'int win32_stat(const char*, _stati64*)':
C:/builds/ab-full/build/ffmpeg-git/libavformat/os_support.h:196:32:
error: cannot convert '_stati64*' to '_stat64*' for argument '2' to
'int _wstat64(const wchar_t*, _stat64*)'
 ret = wfunc(filename_w, par); \
^
C:/builds/ab-full/build/ffmpeg-git/libavformat/os_support.h:206:1:
note: in expansion of macro 'DEF_FS_FUNCTION2'
 DEF_FS_FUNCTION2(stat, _wstat64, _stat64, struct stat*)
 ^
C:/builds/ab-full/build/ffmpeg-git/libavformat/os_support.h:202:36:
error: cannot convert '_stati64*' to '_stat64*' for argument '2' to
'int _stat64(const char*, _stat64*)'
 return afunc(filename_utf8, par); \
^
C:/builds/ab-full/build/ffmpeg-git/libavformat/os_support.h:206:1:
note: in expansion of macro 'DEF_FS_FUNCTION2'
 DEF_FS_FUNCTION2(stat, _wstat64, _stat64, struct stat*)
 ^
make: *** [/build/ffmpeg-git/common.mak:63:
libavdevice/decklink_common.o] Error 1
$ make
CXX libavdevice/decklink_common.o
cc1plus.exe: warning: command line option '-Wdeclaration-after-statement' is 
valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option '-Wmissing-prototypes' is valid for 
C/ObjC but not for C++
cc1plus.exe: warning: command line option '-Wno-pointer-to-int-cast' is valid 
for C/ObjC but not for C++
cc1plus.exe: warning: command line option '-Wstrict-prototypes' is valid for 
C/ObjC but not for C++
cc1plus.exe: warning: command line option '-Wno-pointer-sign' is valid for 
C/ObjC but not for C++
cc1plus.exe: warning: command line option '-std=c99' is valid for C/ObjC but 
not for C++
In file included from 
C:/builds/ab-full/build/ffmpeg-git/libavformat/os_support.h:112:0,
 from 
C:/builds/ab-full/build/ffmpeg-git/libavformat/internal.h:28,
 from 
C:/builds/ab-full/build/ffmpeg-git/libavdevice/decklink_common.cpp:34:
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/winsock2.h:15:2: 
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
 #warning Please include winsock2.h before windows.h
  ^
In file included from 
C:/builds/ab-full/build/ffmpeg-git/libavdevice/decklink_common.cpp:22:0:
C:/builds/ab-full/local32/include/DeckLinkAPI.h:20697:69: warning: redundant 
redeclaration of 'ULONG BSTR_UserSize(ULONG*, ULONG, OLECHAR**)' in same scope 
[-Wredundant-decls]
 ULONG   __RPC_USER BSTR_UserSize (ULONG *, ULONG, BSTR *);
 ^
In file included from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/objbase.h:164:0,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/ole2.h:17,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/wtypes.h:12,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/winscard.h:10,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/windows.h:97,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/rpc.h:16,
 from C:/builds/ab-full/local32/include/DeckLinkAPI.h:7,
 from 
C:/builds/ab-full/build/ffmpeg-git/libavdevice/decklink_common.cpp:22:
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/propidl.h:1287:28: 
note: previous declaration of 'ULONG BSTR_UserSize(ULONG*, ULONG, OLECHAR**)'
 ULONG   __RPC_USER BSTR_UserSize (ULONG *, ULONG, BSTR *);
^
In file included from 
C:/builds/ab-full/build/ffmpeg-git/libavdevice/decklink_common.cpp:22:0:
C:/builds/ab-full/local32/include/DeckLinkAPI.h:20698:79: warning: redundant 
redeclaration of 'unsigned char* BSTR_UserMarshal(ULONG*, unsigned char*, 
OLECHAR**)' in same scope [-Wredundant-decls]
 unsigned char * __RPC_USER BSTR_UserMarshal  (ULONG *, unsigned char *, BSTR 
*);
   ^
In file included from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/objbase.h:164:0,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/ole2.h:17,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/wtypes.h:12,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/winscard.h:10,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/windows.h:97,
 from 
C:/builds/ab-full/msys64/mingw32/i686-w64-mingw32/include/rpc.h:16,
 from C:/builds/ab-full/local32/include/DeckLinkAPI.h:7,
 from 

Re: [FFmpeg-devel] [FFmpeg-cvslog] lavf/os_support.h: Fix for unicode filenames on windows.

2016-06-13 Thread Clément Bœsch
On Tue, Jun 14, 2016 at 07:08:58AM +1000, Matt Oliver wrote:
> On 13 June 2016 at 18:29, Benoit Fouet  wrote:
> 
> > Hi,
> >
> >
> >
> > On 13/06/2016 10:21, Clément Bœsch wrote:
> >
> >> On Mon, Jun 13, 2016 at 05:50:18AM +0200, Matt Oliver wrote:
> >>
> >>> ffmpeg | branch: master | Matt Oliver  | Mon Jun
> >>> 6 17:04:39 2016 +1000| [37787f261639c53998487400e874741c17e85fc6] |
> >>> committer: Matt Oliver
> >>>
> >>> lavf/os_support.h: Fix for unicode filenames on windows.
> >>>
> >>> Fixes #819 #5256 #5281
> >>>
> >>> Signed-off-by: Matt Oliver 
> >>>
> >>>
>  http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37787f261639c53998487400e874741c17e85fc6
> 
> >>> ---
> >>>
> >>>   libavformat/file.c   |4 
> >>>   libavformat/os_support.h |   24 
> >>>   2 files changed, 28 insertions(+)
> >>>
> >>> diff --git a/libavformat/file.c b/libavformat/file.c
> >>> index 5765ce7..264542a 100644
> >>> --- a/libavformat/file.c
> >>> +++ b/libavformat/file.c
> >>> @@ -148,7 +148,11 @@ static int file_check(URLContext *h, int mask)
> >>>   ret |= AVIO_FLAG_WRITE;
> >>>   #else
> >>>   struct stat st;
> >>> +#   ifndef _WIN32
> >>>   ret = stat(filename, );
> >>> +#   else
> >>> +ret = win32_stat(filename, );
> >>> +#   endif
> >>>
> >> why this chunk?
> >>
> >>   if (ret < 0)
> >>>   return AVERROR(errno);
> >>>   diff --git a/libavformat/os_support.h b/libavformat/os_support.h
> >>> index a332911..9e312a5 100644
> >>> --- a/libavformat/os_support.h
> >>> +++ b/libavformat/os_support.h
> >>> @@ -182,6 +182,29 @@ DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
> >>>   DEF_FS_FUNCTION(mkdir,  _wmkdir,  _mkdir)
> >>>   DEF_FS_FUNCTION(rmdir,  _wrmdir , _rmdir)
> >>>   +#define DEF_FS_FUNCTION2(name, wfunc, afunc, partype) \
> >>> +static inline int win32_##name(const char *filename_utf8, partype par) \
> >>> +{ \
> >>> +wchar_t *filename_w;  \
> >>> +int ret;  \
> >>> +  \
> >>> +if (utf8towchar(filename_utf8, _w))  \
> >>> +return -1;\
> >>> +if (!filename_w)  \
> >>> +goto fallback;\
> >>> +  \
> >>> +ret = wfunc(filename_w, par); \
> >>> +av_free(filename_w);  \
> >>> +return ret;   \
> >>> +  \
> >>> +fallback: \
> >>> +/* filename may be be in CP_ACP */\
> >>> +return afunc(filename_utf8, par); \
> >>> +}
> >>> +
> >>> +DEF_FS_FUNCTION2(access, _waccess, _access, int)
> >>> +DEF_FS_FUNCTION2(stat, _wstat64, _stat64, struct stat*)
> >>> +
> >>>   static inline int win32_rename(const char *src_utf8, const char
> >>> *dest_utf8)
> >>>   {
> >>>   wchar_t *src_w, *dest_w;
> >>> @@ -231,6 +254,7 @@ fallback:
> >>>   #define rename  win32_rename
> >>>   #define rmdir   win32_rmdir
> >>>   #define unlink  win32_unlink
> >>> +#define access  win32_access
> >>>
> >>>
> >> ...instead of #define stat win32_stat here?
> >>
> >
> > as already noted by someone else, this should be
> > #define stat(a, b) win32_stat((a), (b))
> > in order not to conflict with "struct stat" definition.
> >
> 
> As stated in the original patch thread a define for the win32_stat function
> can not be used as there is already a define for the 'stat' struct.
> So using:
> #define stat(a, b) win32_stat((a), (b))
> clashes with the existing
> #define stat _stat64
> 
> Since there is a stat function and a stat struct then a macro can only be
> used for one of them and there is already an object macro for the stat
> struct.
> If the suggested "#define stat(a, b) win32_stat((a), (b))" was added this
> overrides the struct macro causing the compiler not to use _stat64 and use
> a 32 variant instead which results in memory corruption.

Sorry, I wasn't following the thread, I just happened to read cvslog.

A comment in the source would probably be welcome though, no one is going
to be aware of these discussions in the future.

-- 
Clément B.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavf/os_support.h: Fix for unicode filenames on windows.

2016-06-13 Thread Matt Oliver
On 13 June 2016 at 18:29, Benoit Fouet  wrote:

> Hi,
>
>
>
> On 13/06/2016 10:21, Clément Bœsch wrote:
>
>> On Mon, Jun 13, 2016 at 05:50:18AM +0200, Matt Oliver wrote:
>>
>>> ffmpeg | branch: master | Matt Oliver  | Mon Jun
>>> 6 17:04:39 2016 +1000| [37787f261639c53998487400e874741c17e85fc6] |
>>> committer: Matt Oliver
>>>
>>> lavf/os_support.h: Fix for unicode filenames on windows.
>>>
>>> Fixes #819 #5256 #5281
>>>
>>> Signed-off-by: Matt Oliver 
>>>
>>>
 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37787f261639c53998487400e874741c17e85fc6

>>> ---
>>>
>>>   libavformat/file.c   |4 
>>>   libavformat/os_support.h |   24 
>>>   2 files changed, 28 insertions(+)
>>>
>>> diff --git a/libavformat/file.c b/libavformat/file.c
>>> index 5765ce7..264542a 100644
>>> --- a/libavformat/file.c
>>> +++ b/libavformat/file.c
>>> @@ -148,7 +148,11 @@ static int file_check(URLContext *h, int mask)
>>>   ret |= AVIO_FLAG_WRITE;
>>>   #else
>>>   struct stat st;
>>> +#   ifndef _WIN32
>>>   ret = stat(filename, );
>>> +#   else
>>> +ret = win32_stat(filename, );
>>> +#   endif
>>>
>> why this chunk?
>>
>>   if (ret < 0)
>>>   return AVERROR(errno);
>>>   diff --git a/libavformat/os_support.h b/libavformat/os_support.h
>>> index a332911..9e312a5 100644
>>> --- a/libavformat/os_support.h
>>> +++ b/libavformat/os_support.h
>>> @@ -182,6 +182,29 @@ DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
>>>   DEF_FS_FUNCTION(mkdir,  _wmkdir,  _mkdir)
>>>   DEF_FS_FUNCTION(rmdir,  _wrmdir , _rmdir)
>>>   +#define DEF_FS_FUNCTION2(name, wfunc, afunc, partype) \
>>> +static inline int win32_##name(const char *filename_utf8, partype par) \
>>> +{ \
>>> +wchar_t *filename_w;  \
>>> +int ret;  \
>>> +  \
>>> +if (utf8towchar(filename_utf8, _w))  \
>>> +return -1;\
>>> +if (!filename_w)  \
>>> +goto fallback;\
>>> +  \
>>> +ret = wfunc(filename_w, par); \
>>> +av_free(filename_w);  \
>>> +return ret;   \
>>> +  \
>>> +fallback: \
>>> +/* filename may be be in CP_ACP */\
>>> +return afunc(filename_utf8, par); \
>>> +}
>>> +
>>> +DEF_FS_FUNCTION2(access, _waccess, _access, int)
>>> +DEF_FS_FUNCTION2(stat, _wstat64, _stat64, struct stat*)
>>> +
>>>   static inline int win32_rename(const char *src_utf8, const char
>>> *dest_utf8)
>>>   {
>>>   wchar_t *src_w, *dest_w;
>>> @@ -231,6 +254,7 @@ fallback:
>>>   #define rename  win32_rename
>>>   #define rmdir   win32_rmdir
>>>   #define unlink  win32_unlink
>>> +#define access  win32_access
>>>
>>>
>> ...instead of #define stat win32_stat here?
>>
>
> as already noted by someone else, this should be
> #define stat(a, b) win32_stat((a), (b))
> in order not to conflict with "struct stat" definition.
>

As stated in the original patch thread a define for the win32_stat function
can not be used as there is already a define for the 'stat' struct.
So using:
#define stat(a, b) win32_stat((a), (b))
clashes with the existing
#define stat _stat64

Since there is a stat function and a stat struct then a macro can only be
used for one of them and there is already an object macro for the stat
struct.
If the suggested "#define stat(a, b) win32_stat((a), (b))" was added this
overrides the struct macro causing the compiler not to use _stat64 and use
a 32 variant instead which results in memory corruption.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavf/os_support.h: Fix for unicode filenames on windows.

2016-06-13 Thread Benoit Fouet

Hi,


On 13/06/2016 10:21, Clément Bœsch wrote:

On Mon, Jun 13, 2016 at 05:50:18AM +0200, Matt Oliver wrote:

ffmpeg | branch: master | Matt Oliver  | Mon Jun  6 
17:04:39 2016 +1000| [37787f261639c53998487400e874741c17e85fc6] | committer: Matt 
Oliver

lavf/os_support.h: Fix for unicode filenames on windows.

Fixes #819 #5256 #5281

Signed-off-by: Matt Oliver 


http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37787f261639c53998487400e874741c17e85fc6

---

  libavformat/file.c   |4 
  libavformat/os_support.h |   24 
  2 files changed, 28 insertions(+)

diff --git a/libavformat/file.c b/libavformat/file.c
index 5765ce7..264542a 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -148,7 +148,11 @@ static int file_check(URLContext *h, int mask)
  ret |= AVIO_FLAG_WRITE;
  #else
  struct stat st;
+#   ifndef _WIN32
  ret = stat(filename, );
+#   else
+ret = win32_stat(filename, );
+#   endif

why this chunk?


  if (ret < 0)
  return AVERROR(errno);
  
diff --git a/libavformat/os_support.h b/libavformat/os_support.h

index a332911..9e312a5 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -182,6 +182,29 @@ DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
  DEF_FS_FUNCTION(mkdir,  _wmkdir,  _mkdir)
  DEF_FS_FUNCTION(rmdir,  _wrmdir , _rmdir)
  
+#define DEF_FS_FUNCTION2(name, wfunc, afunc, partype) \

+static inline int win32_##name(const char *filename_utf8, partype par) \
+{ \
+wchar_t *filename_w;  \
+int ret;  \
+  \
+if (utf8towchar(filename_utf8, _w))  \
+return -1;\
+if (!filename_w)  \
+goto fallback;\
+  \
+ret = wfunc(filename_w, par); \
+av_free(filename_w);  \
+return ret;   \
+  \
+fallback: \
+/* filename may be be in CP_ACP */\
+return afunc(filename_utf8, par); \
+}
+
+DEF_FS_FUNCTION2(access, _waccess, _access, int)
+DEF_FS_FUNCTION2(stat, _wstat64, _stat64, struct stat*)
+
  static inline int win32_rename(const char *src_utf8, const char *dest_utf8)
  {
  wchar_t *src_w, *dest_w;
@@ -231,6 +254,7 @@ fallback:
  #define rename  win32_rename
  #define rmdir   win32_rmdir
  #define unlink  win32_unlink
+#define access  win32_access
  

...instead of #define stat win32_stat here?


as already noted by someone else, this should be
#define stat(a, b) win32_stat((a), (b))
in order not to conflict with "struct stat" definition.

--
Ben

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel