Main MRPT website > C++ reference for MRPT 1.9.9
jinclude.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 /* Include auto-config file to find out which system include files we need. */
11 
12 #include "mrpt_jconfig.h" /* auto configuration options */
13 #define JCONFIG_INCLUDED /* so that mrpt_jpeglib.h doesn't do it again */
14 
15 /*
16  * We need the nullptr macro and size_t typedef.
17  * On an ANSI-conforming system it is sufficient to include <stddef.h>.
18  * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
19  * pull in <sys/types.h> as well.
20  * Note that the core JPEG library does not require <stdio.h>;
21  * only the default error handler and data source/destination modules do.
22  * But we must pull it in because of the references to FILE in mrpt_jpeglib.h.
23  * You can remove those references if you want to compile without <stdio.h>.
24  */
25 
26 #ifdef HAVE_STDDEF_H
27 #include <stddef.h>
28 #endif
29 
30 #ifdef HAVE_STDLIB_H
31 #include <stdlib.h>
32 #endif
33 
34 #ifdef NEED_SYS_TYPES_H
35 #include <sys/types.h>
36 #endif
37 
38 #include <stdio.h>
39 
40 /*
41  * We need memory copying and zeroing functions, plus strncpy().
42  * ANSI and System V implementations declare these in <string.h>.
43  * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
44  * Some systems may declare memset and memcpy in <memory.h>.
45  *
46  * NOTE: we assume the size parameters to these functions are of type size_t.
47  * Change the casts in these macros if not!
48  */
49 
50 #ifdef NEED_BSD_STRINGS
51 
52 #include <strings.h>
53 #define MEMZERO(target, size) bzero((void*)(target), (size_t)(size))
54 #define MEMCOPY(dest, src, size) \
55  bcopy((const void*)(src), (void*)(dest), (size_t)(size))
56 
57 #else /* not BSD, assume ANSI/SysV string lib */
58 
59 #include <string.h>
60 #define MEMZERO(target, size) memset((void*)(target), 0, (size_t)(size))
61 #define MEMCOPY(dest, src, size) \
62  memcpy((void*)(dest), (const void*)(src), (size_t)(size))
63 
64 #endif
65 
66 /*
67  * In ANSI C, and indeed any rational implementation, size_t is also the
68  * type returned by sizeof(). However, it seems there are some irrational
69  * implementations out there, in which sizeof() returns an int even though
70  * size_t is defined as long or unsigned long. To ensure consistent results
71  * we always use this SIZEOF() macro in place of using sizeof() directly.
72  */
73 
74 #define SIZEOF(object) ((size_t)sizeof(object))
75 
76 /*
77  * The modules that use fread() and fwrite() always invoke them through
78  * these macros. On some systems you may need to twiddle the argument casts.
79  * CAUTION: argument order is different from underlying functions!
80  */
81 
82 #define JFREAD(file, buf, sizeofbuf) \
83  ((size_t)fread((void*)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
84 #define JFWRITE(file, buf, sizeofbuf) \
85  ((size_t)fwrite((const void*)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019