LCOV - code coverage report
Current view: top level - include/sal - types.h (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 2 2 100.0 %
Date: 2014-04-14 Functions: 6 177 3.4 %
Legend: Lines: hit not hit

          Line data    Source code
       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 _SAL_TYPES_H_
      21             : #define _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             : 
     124             : /** A legacy synonym for `char`.
     125             : 
     126             :     @deprecated use plain `char` instead.
     127             : */
     128             : typedef char sal_Char;
     129             : 
     130             : /** A legacy synonym for `signed char`.
     131             : 
     132             :     @deprecated use plain `signed char` instead.
     133             : */
     134             : typedef signed char sal_sChar;
     135             : 
     136             : /** A legacy synonym for `unsigned char`.
     137             : 
     138             :     @deprecated use plain `unsigned char` instead.
     139             : */
     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             : 
     280             : /**
     281             :    Exporting the symbols necessary for exception handling on GCC.
     282             : 
     283             :    These macros are used for inline declarations of exception classes, as in
     284             :    rtl/malformeduriexception.hxx.
     285             : */
     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             : 
     298             : /** Use this as markup for functions and methods whose return value must be
     299             :     checked.
     300             : 
     301             :     Compilers that support a construct of this nature will emit a compile
     302             :     time warning on unchecked return value.
     303             : */
     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             : 
     310             : /** Use this for pure virtual classes, e.g. class SAL_NO_VTABLE Foo { ...
     311             :     This hinders the compiler from setting a generic vtable stating that
     312             :     a pure virtual function was called and thus slightly reduces code size.
     313             : */
     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             : 
     324             : /** This is the binary specification of a SAL sequence.
     325             :     <br>
     326             : */
     327             : typedef struct _sal_Sequence
     328             : {
     329             :     /** reference count of sequence<br>
     330             :     */
     331             :     sal_Int32           nRefCount;
     332             :     /** element count<br>
     333             :     */
     334             :     sal_Int32           nElements;
     335             :     /** elements array<br>
     336             :     */
     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             : 
     348             : /** Exception specification documentation.
     349             : 
     350             :     The original intent of this macro was to control whether or not actual
     351             :     exception specifications are emitted, based on how much they impact code
     352             :     size etc. in a specific scenario.  But it ended up always being disabled
     353             :     (except for MSVC, which effectively ignored it even though being enabled),
     354             :     and used in ways that would make enabling it illegal (e.g., in the
     355             :     cppu::ComponentFactoryFunc typedef, or with necessarily incomplete
     356             :     com::sun::star::uno::RuntimeException in com/sun/star/uno/Reference.h), so
     357             :     has officially been demoted to pure documentation now.
     358             : 
     359             :     @deprecated do not use in new code.
     360             : */
     361             : #define SAL_THROW(x)
     362             : 
     363             : /** Nothrow specification for C functions.
     364             : 
     365             :     This is a macro so it can expand to nothing in C code.
     366             : */
     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             : {
     386             :     /** definition of a no acquire enum for ctors
     387             :     */
     388             :     SAL_NO_ACQUIRE
     389             : };
     390             : 
     391             : namespace com { namespace sun { namespace star { } } }
     392             : 
     393             : /** short-circuit extra-verbose API namespaces
     394             : 
     395             :  @since LibreOffice 4.0
     396             : */
     397             : namespace css = ::com::sun::star;
     398             : 
     399             : /** C++11 "= delete" feature.
     400             : 
     401             :     With HAVE_CXX11_DELETE, calling a deleted function will cause a compile-time
     402             :     error, while otherwise it will only cause a link-time error as the declared
     403             :     function is not defined.
     404             : 
     405             :     @since LibreOffice 4.1
     406             : */
     407             : #if HAVE_CXX11_DELETE
     408             : #define SAL_DELETED_FUNCTION = delete
     409             : #else
     410             : #define SAL_DELETED_FUNCTION
     411             : #endif
     412             : 
     413             : /** C++11 "override" feature.
     414             : 
     415             :     With HAVE_CXX11_OVERRIDE, force the method to override a existing method in
     416             :     parent, error out if the method with the correct signature does not exist.
     417             : 
     418             :     @since LibreOffice 4.1
     419             : */
     420             : #if HAVE_CXX11_OVERRIDE
     421             : #define SAL_OVERRIDE override
     422             : #else
     423             : #define SAL_OVERRIDE
     424             : #endif
     425             : 
     426             : /** C++11 "final" feature.
     427             : 
     428             :     With HAVE_CXX11_FINAL, mark a class as non-derivable or a method as non-overridable.
     429             : 
     430             :     @since LibreOffice 4.1
     431             : */
     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             : 
     444             : /**
     445             :    A static_cast between integral types, to avoid C++ compiler warnings.
     446             : 
     447             :    In C++ source code, use sal::static_int_cast<T>(n) instead of
     448             :    static_cast<T>(n) whenever a compiler warning about integral type problems
     449             :    shall be silenced.  That way, source code that needs to be modified when the
     450             :    type of any of the expressions involved in the compiler warning is changed
     451             :    can be found more easily.
     452             : 
     453             :    Both template arguments T1 and T2 must be integral types.
     454             : */
     455    47284485 : template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
     456    47284485 :     return static_cast< T1 >(n);
     457             : }
     458             : 
     459             : }
     460             : 
     461             : #else /* __cplusplus */
     462             : 
     463             : /**
     464             :    A cast between integer types, to avoid C compiler warnings.
     465             : 
     466             :    In C source code, use SAL_INT_CAST(type, expr) instead of ((type) (expr))
     467             :    whenever a compiler warning about integer type problems shall be silenced.
     468             :    That way, source code that needs to be modified when the type of any of the
     469             :    expressions involved in the compiler warning is changed can be found more
     470             :    easily.
     471             : 
     472             :    The argument 'type' must be an integer type and the argument 'expr' must be
     473             :    an integer expression.  Both arguments are evaluated exactly once.
     474             : */
     475             : #define SAL_INT_CAST(type, expr) ((type) (expr))
     476             : 
     477             : #endif /* __cplusplus */
     478             : 
     479             : /**
     480             :     Use as follows:
     481             :         SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);
     482             : */
     483             : 
     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             : 
     494             : /**
     495             :    This macro is used to tag interfaces that are deprecated for both
     496             :    internal and external API users, but where we are still writing
     497             :    out the internal usage. Ultimately these should be replaced by
     498             :    SAL_DEPRECATED, and then removed.
     499             : 
     500             :    Use as follows:
     501             :         SAL_DEPRECATED_INTERNAL("Dont use, its evil.") void doit(int nPara);
     502             :  */
     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             : 
     509             : /**
     510             :     Use as follows:
     511             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     512             :         \::std::auto_ptr<X> ...
     513             :         SAL_WNODEPRECATED_DECLARATIONS_POP
     514             : */
     515             : 
     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             : 
     527             : /**
     528             :    Use as follows:
     529             : 
     530             :    SAL_WNOUNREACHABLE_CODE_PUSH
     531             : 
     532             :    function definition
     533             : 
     534             :    SAL_WNOUNREACHABLE_CODE_POP
     535             : 
     536             :    Useful in cases where the compiler is "too clever" like when doing
     537             :    link-time code generation, and noticing that a called function
     538             :    always throws, and fixing the problem cleanly so that it produceds
     539             :    no warnings in normal non-LTO compilations either is not easy.
     540             : 
     541             : */
     542             : 
     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             : 
     555             : /** Annotate unused but required C++ function parameters.
     556             : 
     557             :     An unused parameter is required if the function needs to adhere to a given
     558             :     type (e.g., if its address is assigned to a function pointer of a specific
     559             :     type, or if it is called from template code).  This annotation helps static
     560             :     analysis tools suppress false warnings.  In the case of virtual functions
     561             :     (where unused required parameters are common, too), the annotation is not
     562             :     required (as static analysis tools can themselves derive the information
     563             :     whether a function is virtual).
     564             : 
     565             :     Use the annotation in function definitions like
     566             : 
     567             :       void f(SAL_UNUSED_PARAMETER int) {}
     568             : 
     569             :     C does not allow unnamed parameters, anyway, so a function definition like
     570             :     the above needs to be written there as
     571             : 
     572             :       void f(int dummy) { (void) dummy; / * avoid warnings * / }
     573             : 
     574             :     without a SAL_UNUSED_PARAMETER annotation.
     575             : 
     576             :     @since LibreOffice 3.6
     577             :  */
     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             : 
     586             : /**
     587             : 
     588             :  Annotate classes where a compiler should warn if an instance is unused.
     589             : 
     590             :  The compiler cannot warn about unused instances if they have non-trivial
     591             :  or external constructors or destructors. Classes marked with SAL_WARN_UNUSED
     592             :  will be warned about.
     593             : 
     594             :  @since LibreOffice 4.0
     595             : 
     596             : */
     597             : 
     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 /*_SAL_TYPES_H_ */
     607             : 
     608             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10