[libdvdnav-devel] [Git][videolan/libdvdread][master] 6 commits: meson: add MSVC headers when compiling with MSVC

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Aug 10 19:41:33 UTC 2025



Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread


Commits:
2694b8ad by Steve Lhomme at 2025-08-08T14:26:24+02:00
meson: add MSVC headers when compiling with MSVC

Remove colloding inttypes.h

- - - - -
2e816c2b by Steve Lhomme at 2025-08-08T14:26:25+02:00
meson: disable warnings for POSIX calls

- - - - -
4e4b7ff2 by Steve Lhomme at 2025-08-08T14:26:25+02:00
dvd_input: add missing include to declare _wopen()

- - - - -
6758b528 by Steve Lhomme at 2025-08-08T14:26:25+02:00
use ptrdiff_t instead of POSIX ssize_t wiht MSVC

ssize_t is not a standard C type. In some cases it's supposed to hold no more
than a long [^1]. That's 2 GB in normal case which is enough for 16k*16k 16-bit
RGBA.

> The implementation shall support one or more programming environments in
> which the widths of blksize_t, pid_t, size_t, ssize_t, and suseconds_t are no
> greater than the width of type long. The names of these programming
> environments can be obtained using the confstr() function or the getconf
> utility.

Make sure the new type is equivalent to the old one so we don't break ABI.
And a recompilation will hopefully no bring any warning (otherwise that was
assumed to be ssize_t by the host app was not correct).

[^1] :https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html

- - - - -
72f1cfca by Steve Lhomme at 2025-08-08T14:26:25+02:00
dvd_reader: add missing macros/defines in MSVC

They were defined in msvc/config.h which is not used with meson.

- - - - -
8fea3a85 by Steve Lhomme at 2025-08-08T14:26:25+02:00
dvd_udf: do not include strings.h with MSVC

It's included for strcasecmp() with is defined in the msvc/include/unistd.h.
And that header doesn't exist in MSVC.

- - - - -


8 changed files:

- meson.build
- msvc/config.h
- − msvc/include/inttypes.h
- src/dvd_input.c
- src/dvd_reader.c
- src/dvd_udf.c
- src/dvdread/dvd_reader.h
- src/meson.build


Changes:

=====================================
meson.build
=====================================
@@ -18,6 +18,10 @@ cdata = configuration_data()
 
 # Include directories
 dvdread_inc_dirs = include_directories('.', 'src', 'src/dvdread')
+if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
+    # extra POSIX headers not found in the Windows SDK
+    dvdread_inc_dirs = [dvdread_inc_dirs, include_directories('msvc/include', 'msvc/contrib/dirent')]
+endif
 
 # The version number for the shared library
 dvdread_soname_version = '8.1.0'


=====================================
msvc/config.h
=====================================
@@ -30,17 +30,10 @@
 
 #define ssize_t __int64
 
-#ifndef PATH_MAX
-#define PATH_MAX MAX_PATH
-#endif
-
 #define strcasecmp stricmp
 #define strncasecmp strnicmp
 
 #define S_ISDIR(m) ((m) & _S_IFDIR)
-#define S_ISREG(m) ((m) & _S_IFREG)
-#define S_ISBLK(m) 0
-#define S_ISCHR(m) 0
 
 /* Fallback types (very x86-centric, sorry) */
 typedef unsigned char       uint8_t;


=====================================
msvc/include/inttypes.h deleted
=====================================
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2000-2001 the xine project
- *
- * This file is part of xine, a unix video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * WIN32 PORT,
- * by Matthew Grooms <elon at altavista.com>
- *
- * inttypes.h - Standard integer definitions.
- *
- */
-
-#ifndef _SYS_INTTYPES_H_
-#define _SYS_INTTYPES_H_
-
-#include <config.h>
-
-#endif


=====================================
src/dvd_input.c
=====================================
@@ -31,6 +31,7 @@
 #ifdef _WIN32
 #include <windows.h>
 #include "../msvc/contrib/win32_cs.h"
+#include <io.h>                      /* _wopen */
 #endif
 
 #include "dvdread/dvd_reader.h"      /* DVD_VIDEO_LB_LEN */


=====================================
src/dvd_reader.c
=====================================
@@ -63,6 +63,15 @@
 # include "msvc/contrib/win32_cs.h"
 #endif
 
+#if defined(_MSC_VER)
+// sys/stat.h values
+#define S_ISREG(m)  (((m) & _S_IFMT) == _S_IFREG)
+#define S_ISBLK(m) 0
+#define S_ISCHR(m) 0
+
+#define PATH_MAX _MAX_PATH
+#endif
+
 /* misc win32 helpers */
 
 #ifdef _WIN32


=====================================
src/dvd_udf.c
=====================================
@@ -32,7 +32,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
+#ifndef _MSC_VER
+# include <strings.h>
+#endif
 
 #include <sys/types.h>
 #include <sys/stat.h>


=====================================
src/dvdread/dvd_reader.h
=====================================
@@ -34,6 +34,10 @@
 #include <inttypes.h>
 #include <stdarg.h>
 
+#ifdef _MSC_VER
+typedef ptrdiff_t ssize_t;
+#endif
+
 #include <dvdread/attributes.h>
 
 /**


=====================================
src/meson.build
=====================================
@@ -22,7 +22,11 @@ dvdread_src = files(
 if host_machine.system() == 'windows' and get_option('default_library') == 'static'
     api_export_flags = []
 else
-    api_export_flags = '-DDVDREAD_API_EXPORT'
+    api_export_flags = ['-DDVDREAD_API_EXPORT']
+endif
+
+if host_machine.system() == 'windows'
+    api_export_flags = [api_export_flags, '-D_CRT_SECURE_NO_WARNINGS']
 endif
 
 # The final libdvdread library
@@ -32,7 +36,7 @@ libdvdread = library('dvdread', dvdread_src,
         libdvdcss_dependency,
         libdl_dependency,
     ],
-    c_args: [api_export_flags],
+    c_args: api_export_flags,
     gnu_symbol_visibility: 'hidden',
     version: dvdread_soname_version,
     install: true,



View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/aa6ccc336d2b39ac418ca713127ecf683c6ef254...8fea3a850daa83ffd9a447ca11cf765504589fd1

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/aa6ccc336d2b39ac418ca713127ecf683c6ef254...8fea3a850daa83ffd9a447ca11cf765504589fd1
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the libdvdnav-devel mailing list