VC6 patches
Posted: 2009-01-14T14:12:44-07:00
Hi,
Because I couldn't get the IM windows binaries to work with VC6 I have downloaded the source and tried to debug the problem myself. Below are the issues I've found with some suggested fixes to get it to work with VC6.
Compile Issues:
--------------------------------------------------------------------------------------------
In nt-base.h Replace
#if !defined(fstat)
# define fstat _fstat64
#endif
With
#if !defined(fstat)
#if _MSC_VER == 1200 // VC6
# define fstat _fstat
#else
# define fstat _fstat64
#endif
#endif
------------------------------------------------------------------------------------------
In nt-base.h Replace
#if !defined(stat) && !defined(__MINGW32__)
# define stat __stat64
#endif
With
#if !defined(stat) && !defined(__MINGW32__)
#if _MSC_VER == 1200 // VC6
# define fstat _stat
#else
# define fstat _stat64
#endif
#endif
------------------------------------------------------------------------------------------
In quantum-private.h Replace
static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
const QuantumAny range)
{
return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
}
static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
const QuantumAny range)
{
return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
}
with
static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
const QuantumAny range)
{
#if _MSC_VER == 1200 // VC6
return((Quantum) (((MagickRealType) QuantumRange*(__int64)quantum)/(__int64)range+0.5));
#else
return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
#endif
}
static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
const QuantumAny range)
{
#if _MSC_VER == 1200 // VC6
return((QuantumAny) (((MagickRealType) (__int64)range*(__int64)quantum)/QuantumRange+0.5));
#else
return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
#endif
}
------------------------------------------------------------------------------------------
In string.c (function FormatMagickSize) Replace
length=(double) size;
with
#if _MSC_VER == 1200 // VC6
length=(double)((__int64) size);
#else
length=(double) size;
#endif
------------------------------------------------------------------------------------------
I'm not sure if there is a bug in NTGetModulePath or where it is being used. Firstly, where you have
...NTGetModulePath("CORE_RL_magick_.dll",... would it also be possible to include a test for "CORE_DB_magick_.dll" so that it works in debug?
As far as I can tell, the intent of NTGetModulePath is to return the directory the supplied module resides in BUT WITHOUT appending the module to the returned path string?
I'm confused though because after a successful call to NTGetModulePath, the returned path is checked for validity by passing it to IsPathAccessible. However, IsPathAccessible bases its check on whether the path points to a regular file or not and hence fails because path only contains the directory? If NTGetModulePath returned the directory with the file appended I think it would start working?
cheers,
Mark
if (NTGetModulePath("CORE_RL_magick_.dll",module_path) != MagickFalse)
Because I couldn't get the IM windows binaries to work with VC6 I have downloaded the source and tried to debug the problem myself. Below are the issues I've found with some suggested fixes to get it to work with VC6.
Compile Issues:
--------------------------------------------------------------------------------------------
In nt-base.h Replace
#if !defined(fstat)
# define fstat _fstat64
#endif
With
#if !defined(fstat)
#if _MSC_VER == 1200 // VC6
# define fstat _fstat
#else
# define fstat _fstat64
#endif
#endif
------------------------------------------------------------------------------------------
In nt-base.h Replace
#if !defined(stat) && !defined(__MINGW32__)
# define stat __stat64
#endif
With
#if !defined(stat) && !defined(__MINGW32__)
#if _MSC_VER == 1200 // VC6
# define fstat _stat
#else
# define fstat _stat64
#endif
#endif
------------------------------------------------------------------------------------------
In quantum-private.h Replace
static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
const QuantumAny range)
{
return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
}
static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
const QuantumAny range)
{
return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
}
with
static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
const QuantumAny range)
{
#if _MSC_VER == 1200 // VC6
return((Quantum) (((MagickRealType) QuantumRange*(__int64)quantum)/(__int64)range+0.5));
#else
return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
#endif
}
static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
const QuantumAny range)
{
#if _MSC_VER == 1200 // VC6
return((QuantumAny) (((MagickRealType) (__int64)range*(__int64)quantum)/QuantumRange+0.5));
#else
return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
#endif
}
------------------------------------------------------------------------------------------
In string.c (function FormatMagickSize) Replace
length=(double) size;
with
#if _MSC_VER == 1200 // VC6
length=(double)((__int64) size);
#else
length=(double) size;
#endif
------------------------------------------------------------------------------------------
I'm not sure if there is a bug in NTGetModulePath or where it is being used. Firstly, where you have
...NTGetModulePath("CORE_RL_magick_.dll",... would it also be possible to include a test for "CORE_DB_magick_.dll" so that it works in debug?
As far as I can tell, the intent of NTGetModulePath is to return the directory the supplied module resides in BUT WITHOUT appending the module to the returned path string?
I'm confused though because after a successful call to NTGetModulePath, the returned path is checked for validity by passing it to IsPathAccessible. However, IsPathAccessible bases its check on whether the path points to a regular file or not and hence fails because path only contains the directory? If NTGetModulePath returned the directory with the file appended I think it would start working?
cheers,
Mark
if (NTGetModulePath("CORE_RL_magick_.dll",module_path) != MagickFalse)