From f5f3c951bf8014a779ccfb2005636cef229995ce Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 19 Oct 2013 23:18:11 +0100 Subject: [PATCH] Additional goes and woes in the VS projects to get it all to work together. snprintf definition should go in config.h If Win32 is enabled and Joliet no, it fails. Joliet should be enabled. vsnprintf definition should go in config.h lseek64 is defined as _lseeki64 in Windows SDK. types.h should go to correct place for manually created unistd.h in VS Macros with arguments are defined differently in GCC than in VS. --- MSVC/cd-info.vcxproj | 27 ++++++++++++------------- MSVC/cd-info.vcxproj.filters | 9 +++++++++ MSVC/config.h | 18 ++++++++++++++--- MSVC/libcdio.vcxproj | 8 ++++++++ include/cdio/types.h | 3 ++- lib/driver/MSWindows/win32_ioctl.c | 2 -- src/util.h | 32 ++++++++++++++++++++++-------- 7 files changed, 71 insertions(+), 28 deletions(-) diff --git a/MSVC/cd-info.vcxproj b/MSVC/cd-info.vcxproj index f86789f0..56511103 100644 --- a/MSVC/cd-info.vcxproj +++ b/MSVC/cd-info.vcxproj @@ -82,7 +82,7 @@ Disabled - ..\include\cdio;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) + ..\MSVC;..\include;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;HAVE_WINDOWS_H;%(PreprocessorDefinitions) true EnableFastChecks @@ -94,7 +94,7 @@ EditAndContinue - libcdiod.lib;winmm.lib;%(AdditionalDependencies) + libcdiod.lib;msvcrtd.lib;winmm.lib;%(AdditionalDependencies) $(ProjectName)/$(OutDir)cd-info.exe Debug;%(AdditionalLibraryDirectories) true @@ -106,7 +106,7 @@ Disabled - ..\include\cdio;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) + ..\MSVC;..\include;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H;HAVE_WINDOWS_H;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -118,17 +118,15 @@ ProgramDatabase - libcdiod.lib;winmm.lib;%(AdditionalDependencies) - $(ProjectName)/$(OutDir)cd-info.exe - Debug;%(AdditionalLibraryDirectories) + libcdiod.lib;msvcrtd.lib;winmm.lib;%(AdditionalDependencies) + x64\Debug;%(AdditionalLibraryDirectories) true - $(ProjectName)/$(OutDir)cd-info.pdb Console - ..\include\cdio;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) + ..\MSVC;..\include;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;HAVE_WINDOWS_H;%(PreprocessorDefinitions) MultiThreaded @@ -138,7 +136,7 @@ ProgramDatabase - libcdio.lib;winmm.lib;%(AdditionalDependencies) + libcdio.lib;msvcrt.lib;winmm.lib;%(AdditionalDependencies) $(ProjectName)/$(OutDir)cd-info.exe Release;%(AdditionalLibraryDirectories) true @@ -151,7 +149,7 @@ - ..\include\cdio;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) + ..\MSVC;..\include;..\src;..\lib\driver;..\lib\iso9660;..\lib\udf;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H;HAVE_WINDOWS_H;%(PreprocessorDefinitions) MultiThreaded @@ -162,11 +160,9 @@ ProgramDatabase - libcdio.lib;winmm.lib;%(AdditionalDependencies) - $(ProjectName)/$(OutDir)cd-info.exe - Release;%(AdditionalLibraryDirectories) + libcdio.lib;msvcrt.lib;winmm.lib;%(AdditionalDependencies) + x64\Release;%(AdditionalLibraryDirectories) true - $(ProjectName)/$(OutDir)$(ProjectName).pdb Console true true @@ -174,6 +170,9 @@ + + + diff --git a/MSVC/cd-info.vcxproj.filters b/MSVC/cd-info.vcxproj.filters index 0ce770cb..a9749666 100644 --- a/MSVC/cd-info.vcxproj.filters +++ b/MSVC/cd-info.vcxproj.filters @@ -21,6 +21,15 @@ Source Files + + Source Files + + + Source Files + + + Source Files + diff --git a/MSVC/config.h b/MSVC/config.h index 22c18c58..73d19234 100644 --- a/MSVC/config.h +++ b/MSVC/config.h @@ -59,7 +59,7 @@ /* Define 1 if you want ISO-9660 Joliet extension support. You must have also libiconv installed to get Joliet extension support. */ -#undef HAVE_JOLIET +#define HAVE_JOLIET 1 /* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET @@ -92,7 +92,12 @@ #define HAVE_MEMSET 1 /* Define to 1 if you have the `snprintf' function. */ -#define HAVE_SNPRINTF 1 +#if !defined(HAVE_SNPRINTF) +# if defined (_MSC_VER) +# define HAVE_SNPRINTF 1 +# define snprintf _snprintf +# endif +#endif /*HAVE_SNPRINTF*/ /* Define 1 if you have Solaris CD-ROM support */ #undef HAVE_SOLARIS_CDROM @@ -140,7 +145,12 @@ #undef HAVE_VCDINFO /* Define to 1 if you have the `vsnprintf' function. */ -#define HAVE_VSNPRINTF 1 +#if !defined(HAVE_VSNPRINTF) +# if defined (_MSC_VER) +# define vsnprintf _vsnprintf +# define HAVE_VSNPRINTF 1 +# endif +#endif /*HAVE_SNPRINTF*/ /* Define 1 if you have MinGW CD-ROM support */ #define HAVE_WIN32_CDROM 1 @@ -150,6 +160,8 @@ /* Windows SDK includes seek64 */ #define HAVE_LSEEK64 1 +/* And names it differently */ +#define lseek64 _lseeki64 #define _FILE_OFFSET_BITS 64 /* Define as const if the declaration of iconv() needs const. */ diff --git a/MSVC/libcdio.vcxproj b/MSVC/libcdio.vcxproj index 8ec37803..184e1e3f 100644 --- a/MSVC/libcdio.vcxproj +++ b/MSVC/libcdio.vcxproj @@ -86,6 +86,7 @@ $(OutDir)$(ProjectName)d.lib + msvcrtd.lib @@ -102,6 +103,7 @@ $(OutDir)$(ProjectName)d.lib + msvcrtd.lib @@ -113,6 +115,9 @@ Level3 ProgramDatabase + + msvcrt.lib + @@ -124,6 +129,9 @@ Level3 ProgramDatabase + + msvcrt.lib + diff --git a/include/cdio/types.h b/include/cdio/types.h index b046842b..c6a13ead 100644 --- a/include/cdio/types.h +++ b/include/cdio/types.h @@ -54,8 +54,9 @@ typedef uint8_t ubyte; to compensate for missing UNIX types is to include a custom unistd.h that defines them. Such a file is provided with the libcdio source, in the MSVC/missing directory */ +// Natalia Portillo: the missing directory does not appear in the whole git history, I recreated it. #if defined(_MSC_VER) -#include +#include #endif /* default HP/UX macros are broken */ diff --git a/lib/driver/MSWindows/win32_ioctl.c b/lib/driver/MSWindows/win32_ioctl.c index 030326f5..9edbbaa6 100755 --- a/lib/driver/MSWindows/win32_ioctl.c +++ b/lib/driver/MSWindows/win32_ioctl.c @@ -61,8 +61,6 @@ #include #include "cdio/logging.h" -#define snprintf _snprintf; // Windows prepends with underscore. - #if defined (_XBOX) #define windows_error(loglevel,i_err) { \ cdio_log(loglevel, "Error: file %s: line %d (%s) %ld\n", \ diff --git a/src/util.h b/src/util.h index c554c3b7..36dc0159 100644 --- a/src/util.h +++ b/src/util.h @@ -84,18 +84,34 @@ # define EXIT_INFO 100 #endif -#define DEBUG 1 -#if DEBUG -#define dbg_print(level, s, args...) \ - if (opts.debug_level >= level) \ - report(stderr, "%s: "s, __func__ , ##args) +//# define DEBUG 1 +#ifdef _MSC_VER +# if DEBUG +# define dbg_print(level, s, args, ...) \ + if (opts.debug_level >= level) \ + report(stderr, "%s: "s, __func__ , ##args) +# else +# define dbg_print(level, s, args, ...) +# endif #else -#define dbg_print(level, s, args...) +# if DEBUG +# define dbg_print(level, s, args...) \ + if (opts.debug_level >= level) \ + report(stderr, "%s: "s, __func__ , ##args) +# else +# define dbg_print(level, s, args...) +# endif #endif -#define err_exit(fmt, args...) \ +#ifdef _MSC_VER +#define err_exit(fmt, args, ...) \ report(stderr, "%s: "fmt, program_name, ##args); \ - myexit(p_cdio, EXIT_FAILURE) + myexit(p_cdio, EXIT_FAILURE) +#else +# define err_exit(fmt, args...) \ + report(stderr, "%s: "fmt, program_name, ##args); \ + myexit(p_cdio, EXIT_FAILURE) +#endif typedef enum {