jinclude.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * jinclude.h
  3. *
  4. * Copyright (C) 1991-1994, Thomas G. Lane.
  5. * This file is part of the Independent JPEG Group's software.
  6. * For conditions of distribution and use, see the accompanying README file.
  7. *
  8. * This file exists to provide a single place to fix any problems with
  9. * including the wrong system include files. (Common problems are taken
  10. * care of by the standard jconfig symbols, but on really weird systems
  11. * you may have to edit this file.)
  12. *
  13. * NOTE: this file is NOT intended to be included by applications using the
  14. * JPEG library. Most applications need only include jpeglib.h.
  15. */
  16. #ifdef _WIN32
  17. #pragma warning(disable : 4018) // signed/unsigned mismatch
  18. #pragma warning(disable : 4032)
  19. #pragma warning(disable : 4051)
  20. #pragma warning(disable : 4057) // slightly different base types
  21. #pragma warning(disable : 4100) // unreferenced formal parameter
  22. #pragma warning(disable : 4115)
  23. #pragma warning(disable : 4125) // decimal digit terminates octal escape sequence
  24. #pragma warning(disable : 4127) // conditional expression is constant
  25. #pragma warning(disable : 4136)
  26. #pragma warning(disable : 4152) // nonstandard extension, function/data pointer conversion in expression
  27. #pragma warning(disable : 4201)
  28. #pragma warning(disable : 4214)
  29. #pragma warning(disable : 4244)
  30. #pragma warning(disable : 4305) // truncation from const double to float
  31. #pragma warning(disable : 4310) // cast truncates constant value
  32. #pragma warning(disable: 4505) // unreferenced local function has been removed
  33. #pragma warning(disable : 4514)
  34. #pragma warning(disable : 4702) // unreachable code
  35. #pragma warning(disable : 4711) // selected for automatic inline expansion
  36. #pragma warning(disable : 4220) // varargs matches remaining parameters
  37. #pragma warning(disable : 4761) // integral size mismatch
  38. #endif
  39. /* Include auto-config file to find out which system include files we need. */
  40. #include "../jpeg-6/jconfig.h" /* auto configuration options */
  41. #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
  42. /*
  43. * We need the NULL macro and size_t typedef.
  44. * On an ANSI-conforming system it is sufficient to include <stddef.h>.
  45. * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
  46. * pull in <sys/types.h> as well.
  47. * Note that the core JPEG library does not require <stdio.h>;
  48. * only the default error handler and data source/destination modules do.
  49. * But we must pull it in because of the references to FILE in jpeglib.h.
  50. * You can remove those references if you want to compile without <stdio.h>.
  51. */
  52. #ifdef HAVE_STDDEF_H
  53. #include <stddef.h>
  54. #endif
  55. #ifdef HAVE_STDLIB_H
  56. #include <stdlib.h>
  57. #endif
  58. #ifdef NEED_SYS_TYPES_H
  59. #include <sys/types.h>
  60. #endif
  61. #include <stdio.h>
  62. /*
  63. * We need memory copying and zeroing functions, plus strncpy().
  64. * ANSI and System V implementations declare these in <string.h>.
  65. * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
  66. * Some systems may declare memset and memcpy in <memory.h>.
  67. *
  68. * NOTE: we assume the size parameters to these functions are of type size_t.
  69. * Change the casts in these macros if not!
  70. */
  71. #ifdef NEED_BSD_STRINGS
  72. #include <strings.h>
  73. #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
  74. #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
  75. #else /* not BSD, assume ANSI/SysV string lib */
  76. #include <string.h>
  77. #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
  78. #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
  79. #endif
  80. /*
  81. * In ANSI C, and indeed any rational implementation, size_t is also the
  82. * type returned by sizeof(). However, it seems there are some irrational
  83. * implementations out there, in which sizeof() returns an int even though
  84. * size_t is defined as long or unsigned long. To ensure consistent results
  85. * we always use this SIZEOF() macro in place of using sizeof() directly.
  86. */
  87. #define SIZEOF(object) ((size_t) sizeof(object))
  88. /*
  89. * The modules that use fread() and fwrite() always invoke them through
  90. * these macros. On some systems you may need to twiddle the argument casts.
  91. * CAUTION: argument order is different from underlying functions!
  92. */
  93. #define JFREAD(file,buf,sizeofbuf) \
  94. ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  95. #define JFWRITE(file,buf,sizeofbuf) \
  96. ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))