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



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019