LibreOffice LibreOffice 4.3 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
types.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #ifndef INCLUDED_SAL_TYPES_H
21 #define INCLUDED_SAL_TYPES_H
22
23 #include <sal/config.h>
24 #include <sal/macros.h>
25
26 #include <sal/typesizes.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #if defined ( __MINGW32__ ) && !defined ( __USE_MINGW_ANSI_STDIO )
33 /* Define to use the C99 formatting string for coherence reasons.
34 * In mingw-w64 some functions are ported to the ms formatting string
35 * some are not yet. This is the only way to make the formatting
36 * strings work all the time
37 */
38 #define __USE_MINGW_ANSI_STDIO 1
39 #endif
40
41 /********************************************************************************/
42 /* Data types
43 */
44
45 /* Boolean */
46 typedef unsigned char sal_Bool;
47 # define sal_False ((sal_Bool)0)
48 # define sal_True ((sal_Bool)1)
49
50 /* char is assumed to always be 1 byte long */
51 typedef signed char sal_Int8;
52 typedef unsigned char sal_uInt8;
53
54 #if SAL_TYPES_SIZEOFSHORT == 2
55 typedef signed short sal_Int16;
56 typedef unsigned short sal_uInt16;
57 #else
58 #error "Could not find 16-bit type, add support for your architecture"
59 #endif
60
61 #if SAL_TYPES_SIZEOFLONG == 4
62 typedef signed long sal_Int32;
63 typedef unsigned long sal_uInt32;
64 #define SAL_PRIdINT32 "ld"
65 #define SAL_PRIuUINT32 "lu"
66 #define SAL_PRIxUINT32 "lx"
67 #define SAL_PRIXUINT32 "lX"
68 #elif SAL_TYPES_SIZEOFINT == 4
69 typedef signed int sal_Int32;
70 typedef unsigned int sal_uInt32;
71 #define SAL_PRIdINT32 "d"
72 #define SAL_PRIuUINT32 "u"
73 #define SAL_PRIxUINT32 "x"
74 #define SAL_PRIXUINT32 "X"
75 #else
76 #error "Could not find 32-bit type, add support for your architecture"
77 #endif
78
79 #ifdef _MSC_VER
80 typedef __int64 sal_Int64;
81 typedef unsigned __int64 sal_uInt64;
82
83 /* The following are macros that will add the 64 bit constant suffix. */
84 #define SAL_CONST_INT64(x) x##i64
85 #define SAL_CONST_UINT64(x) x##ui64
86
87 #define SAL_PRIdINT64 "I64d"
88 #define SAL_PRIuUINT64 "I64u"
89 #define SAL_PRIxUINT64 "I64x"
90 #define SAL_PRIXUINT64 "I64X"
91 #elif defined (__GNUC__)
92 #if SAL_TYPES_SIZEOFLONG == 8
93 typedef signed long int sal_Int64;
94 typedef unsigned long int sal_uInt64;
95
96
97 /* The following are macros that will add the 64 bit constant suffix. */
98 #define SAL_CONST_INT64(x) x##l
99 #define SAL_CONST_UINT64(x) x##ul
100
101 #define SAL_PRIdINT64 "ld"
102 #define SAL_PRIuUINT64 "lu"
103 #define SAL_PRIxUINT64 "lx"
104 #define SAL_PRIXUINT64 "lX"
105 #elif SAL_TYPES_SIZEOFLONGLONG == 8
106 typedef signed long long sal_Int64;
107 typedef unsigned long long sal_uInt64;
108
109 /* The following are macros that will add the 64 bit constant suffix. */
110 #define SAL_CONST_INT64(x) x##ll
111 #define SAL_CONST_UINT64(x) x##ull
112
113 #define SAL_PRIdINT64 "lld"
114 #define SAL_PRIuUINT64 "llu"
115 #define SAL_PRIxUINT64 "llx"
116 #define SAL_PRIXUINT64 "llX"
117 #else
118 #error "Could not find 64-bit type, add support for your architecture"
119 #endif
120 #else
121 #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
122 #endif
123
128 typedef char sal_Char;
129
134 typedef signed char sal_sChar;
135
140 typedef unsigned char sal_uChar;
141
142 #if ( defined(SAL_W32) && !defined(__MINGW32__) )
143 // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx
144 // "By default wchar_t is a typedef for unsigned short."
145 // But MinGW has a native wchar_t, and on many places, we cannot deal with
146 // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there.
147 typedef wchar_t sal_Unicode;
148 #else
149 #define SAL_UNICODE_NOTEQUAL_WCHAR_T
150 typedef sal_uInt16 sal_Unicode;
151 #endif
152
153 typedef void * sal_Handle;
154
155 /* sal_Size should currently be the native width of the platform */
156 #if SAL_TYPES_SIZEOFPOINTER == 4
157 typedef sal_uInt32 sal_Size;
158 typedef sal_Int32 sal_sSize;
159 #elif SAL_TYPES_SIZEOFPOINTER == 8
160 typedef sal_uInt64 sal_Size;
161 typedef sal_Int64 sal_sSize;
162 #else
163 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
164 #endif
165
166 /* sal_PtrDiff holds the result of a pointer subtraction */
167 #if SAL_TYPES_SIZEOFPOINTER == 4
168 typedef sal_Int32 sal_PtrDiff;
169 #elif SAL_TYPES_SIZEOFPOINTER == 8
170 typedef sal_Int64 sal_PtrDiff;
171 #else
172 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
173 #endif
174
175 /* printf-style conversion specification length modifiers for size_t and
176 ptrdiff_t (most platforms support C99, MSC has its own extension) */
177 #if defined(_MSC_VER)
178 #define SAL_PRI_SIZET "I"
179 #define SAL_PRI_PTRDIFFT "I"
180 #else
181 #define SAL_PRI_SIZET "z"
182 #define SAL_PRI_PTRDIFFT "t"
183 #endif
184
185 /* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
186 * pointer to void can be converted to this type and back to a pointer to void and the
187 * result will compare to the original pointer */
188 #if SAL_TYPES_SIZEOFPOINTER == 4
189 typedef sal_Int32 sal_IntPtr;
190 typedef sal_uInt32 sal_uIntPtr;
191 #define SAL_PRIdINTPTR SAL_PRIdINT32
192 #define SAL_PRIuUINTPTR SAL_PRIuUINT32
193 #define SAL_PRIxUINTPTR SAL_PRIxUINT32
194 #define SAL_PRIXUINTPTR SAL_PRIXUINT32
195 #elif SAL_TYPES_SIZEOFPOINTER == 8
196 typedef sal_Int64 sal_IntPtr;
197 typedef sal_uInt64 sal_uIntPtr;
198 #define SAL_PRIdINTPTR SAL_PRIdINT64
199 #define SAL_PRIuUINTPTR SAL_PRIuUINT64
200 #define SAL_PRIxUINTPTR SAL_PRIxUINT64
201 #define SAL_PRIXUINTPTR SAL_PRIXUINT64
202 #else
203 #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
204 #endif
205
206 /********************************************************************************/
207 /* Useful defines
208 */
209
210 /* The following SAL_MIN_INTn defines codify the assumption that the signed
211 * sal_Int types use two's complement representation. Defining them as
212 * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
213 * unary minus operator to unsigned quantities.
214 */
215 #define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
216 #define SAL_MAX_INT8 ((sal_Int8) 0x7F)
217 #define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
218 #define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
219 #define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
220 #define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
221 #define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
222 #define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
223 #define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
224 #define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
225 #define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
226 #define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
227
228 #if SAL_TYPES_SIZEOFLONG == 4
229 #define SAL_MAX_SSIZE SAL_MAX_INT32
230 #define SAL_MAX_SIZE SAL_MAX_UINT32
231 #elif SAL_TYPES_SIZEOFLONG == 8
232 #define SAL_MAX_SSIZE SAL_MAX_INT64
233 #define SAL_MAX_SIZE SAL_MAX_UINT64
234 #endif
235
236 #if defined(SAL_W32) || defined(SAL_UNX)
237 # define SAL_MAX_ENUM 0x7fffffff
238 #endif
239
240 #if defined(_MSC_VER) || defined(__MINGW32__)
241 # define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
242 # define SAL_JNI_EXPORT __declspec(dllexport)
243 #if defined(_MSC_VER)
244 # define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
245 #else
246 # define SAL_DLLPUBLIC_IMPORT
247 #endif // defined(_MSC_VER)
248 # define SAL_DLLPRIVATE
249 # define SAL_DLLPUBLIC_TEMPLATE
250 # define SAL_CALL __cdecl
251 # define SAL_CALL_ELLIPSE __cdecl
252 #elif defined SAL_UNX
253 # if defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
254 # if defined(DISABLE_DYNLOADING)
255 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("hidden")))
256 # define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
257 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
258 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
259 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
260 # else
261 # define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
262 # define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
263 # define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
264 # define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
265 # define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
266 # endif
267 # else
268 # define SAL_DLLPUBLIC_EXPORT
269 # define SAL_JNI_EXPORT
270 # define SAL_DLLPUBLIC_IMPORT
271 # define SAL_DLLPRIVATE
272 # define SAL_DLLPUBLIC_TEMPLATE
273 # endif
274 # define SAL_CALL
275 # define SAL_CALL_ELLIPSE
276 #else
277 # error("unknown platform")
278 #endif
279
286 #if defined(__GNUC__) && ! defined(__MINGW32__)
287 # if defined(DISABLE_DYNLOADING)
288 # define SAL_EXCEPTION_DLLPUBLIC_EXPORT __attribute__((visibility("default")))
289 # else
290 # define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
291 # endif
292 # define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
293 #else
294 # define SAL_EXCEPTION_DLLPUBLIC_EXPORT
295 # define SAL_EXCEPTION_DLLPRIVATE
296 #endif
297
304 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
305 # define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
306 #else
307 # define SAL_WARN_UNUSED_RESULT
308 #endif
309
314 #ifdef _MSC_VER
315 # define SAL_NO_VTABLE __declspec(novtable)
316 #else
317 # define SAL_NO_VTABLE
318 #endif
319
320 #ifdef SAL_W32
321 # pragma pack(push, 8)
322 #endif
323
327 typedef struct _sal_Sequence
328 {
331 sal_Int32 nRefCount;
334 sal_Int32 nElements;
337 char elements[1];
338 } sal_Sequence;
339
340 #define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements)
341
342 #if defined( SAL_W32)
343 #pragma pack(pop)
344 #endif
345
346 #if defined __cplusplus
347
361 #define SAL_THROW(x)
362
367 #define SAL_THROW_EXTERN_C() throw ()
368
369 #else
370
371 /* SAL_THROW() must not be used in C code, only SAL_THROW_EXTERN_C() is defined
372 there:
373 */
374 #define SAL_THROW_EXTERN_C()
375
376 #endif
377
378 #ifdef __cplusplus
379 }
380 #endif /* __cplusplus */
381
382 #ifdef __cplusplus
383
384 enum __sal_NoAcquire
385 {
388 SAL_NO_ACQUIRE
389 };
390
391 namespace com { namespace sun { namespace star { } } }
392
397 namespace css = ::com::sun::star;
398
407 #if HAVE_CXX11_DELETE
408 #define SAL_DELETED_FUNCTION = delete
409 #else
410 #define SAL_DELETED_FUNCTION
411 #endif
412
420 #if HAVE_CXX11_OVERRIDE
421 #define SAL_OVERRIDE override
422 #else
423 #define SAL_OVERRIDE
424 #endif
425
432 #if HAVE_CXX11_FINAL
433 #define SAL_FINAL final
434 #else
435 #define SAL_FINAL
436 #endif
437
438 #endif /* __cplusplus */
439
440 #ifdef __cplusplus
441
442 namespace sal {
443
455 template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
456 return static_cast< T1 >(n);
457 }
458
459 }
460
461 #else /* __cplusplus */
462
475 #define SAL_INT_CAST(type, expr) ((type) (expr))
476
477 #endif /* __cplusplus */
478
484 #if HAVE_GCC_DEPRECATED_MESSAGE
485 # define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
486 #elif (__GNUC__)
487 # define SAL_DEPRECATED(message) __attribute__((deprecated))
488 #elif defined(_MSC_VER)
489 # define SAL_DEPRECATED(message) __declspec(deprecated(message))
490 #else
491 # define SAL_DEPRECATED(message)
492 #endif
493
503 #ifdef LIBO_INTERNAL_ONLY
504 # define SAL_DEPRECATED_INTERNAL(message)
505 #else
506 # define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
507 #endif
508
516 #if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY && HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE && HAVE_GCC_PRAGMA_OPERATOR
517 #define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
518 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
519 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
520 #define SAL_WNODEPRECATED_DECLARATIONS_POP \
521 _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
522 #else
523 # define SAL_WNODEPRECATED_DECLARATIONS_PUSH
524 # define SAL_WNODEPRECATED_DECLARATIONS_POP
525 #endif
526
543 #ifdef _MSC_VER
544 #define SAL_WNOUNREACHABLE_CODE_PUSH \
545 __pragma(warning(push)) \
546 __pragma(warning(disable:4702))
547 #define SAL_WNOUNREACHABLE_CODE_POP \
548 __pragma(warning(pop))
549 #else
550 /* Add definitions for GCC and Clang if needed */
551 #define SAL_WNOUNREACHABLE_CODE_PUSH
552 #define SAL_WNOUNREACHABLE_CODE_POP
553 #endif
554
578 #if defined __cplusplus
579 #if defined __GNUC__
580 #define SAL_UNUSED_PARAMETER __attribute__ ((unused))
581 #else
582 #define SAL_UNUSED_PARAMETER
583 #endif
584 #endif
585
598 #if HAVE_GCC_ATTRIBUTE_WARN_UNUSED
599 #define SAL_WARN_UNUSED __attribute__((warn_unused))
600 #elif defined __clang__
601 #define SAL_WARN_UNUSED __attribute__((annotate("lo_warn_unused")))
602 #else
603 #define SAL_WARN_UNUSED
604 #endif
605
606 #endif // INCLUDED_SAL_TYPES_H
607
608 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_sChar
signed char sal_sChar
A legacy synonym for signed char.
Definition: types.h:134
sal_Bool
unsigned char sal_Bool
Definition: types.h:46
SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:388
sal
Definition: types.h:442
com::sun::star
Definition: types.h:391
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:384
sal_Handle
void * sal_Handle
Definition: types.h:153
sal_uInt8
unsigned char sal_uInt8
Definition: types.h:52
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:128
sal_uChar
unsigned char sal_uChar
A legacy synonym for unsigned char.
Definition: types.h:140
_sal_Sequence
This is the binary specification of a SAL sequence.
Definition: types.h:327
sal_Int8
signed char sal_Int8
Definition: types.h:51
_sal_Sequence::elements
char elements[1]
elements array
Definition: types.h:337
_sal_Sequence::nElements
sal_Int32 nElements
element count
Definition: types.h:334
macros.h
sal::static_int_cast
T1 static_int_cast(T2 n)
A static_cast between integral types, to avoid C++ compiler warnings.
Definition: types.h:455
config.h
sal_Sequence
struct _sal_Sequence sal_Sequence
This is the binary specification of a SAL sequence.
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:150
typesizes.h
com
Definition: types.h:391
_sal_Sequence::nRefCount
sal_Int32 nRefCount
reference count of sequence
Definition: types.h:331