LCOV - code coverage report
Current view: top level - include/sal - types.h (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 2 100.0 %
Date: 2015-06-13 12:38:46 Functions: 102 152 67.1 %
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 INCLUDED_SAL_TYPES_H
      21             : #define INCLUDED_SAL_TYPES_H
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <stddef.h>
      26             : 
      27             : #include <sal/macros.h>
      28             : #include <sal/typesizes.h>
      29             : 
      30             : #ifdef __cplusplus
      31             : extern "C" {
      32             : #endif
      33             : 
      34             : #if defined ( __MINGW32__ ) && !defined ( __USE_MINGW_ANSI_STDIO )
      35             : /* Define to use the C99 formatting string for coherence reasons.
      36             :  * In mingw-w64 some functions are ported to the ms formatting string
      37             :  * some are not yet. This is the only way to make the formatting
      38             :  * strings work all the time
      39             :  */
      40             : #define __USE_MINGW_ANSI_STDIO 1
      41             : #endif
      42             : 
      43             : /********************************************************************************/
      44             : /* Data types
      45             : */
      46             : 
      47             : /* Boolean */
      48             : typedef unsigned char sal_Bool;
      49             : #   define sal_False ((sal_Bool)0)
      50             : #   define sal_True  ((sal_Bool)1)
      51             : 
      52             : /* char is assumed to always be 1 byte long */
      53             : typedef signed char         sal_Int8;
      54             : typedef unsigned char       sal_uInt8;
      55             : 
      56             : #if SAL_TYPES_SIZEOFSHORT == 2
      57             :     typedef signed short      sal_Int16;
      58             :     typedef unsigned short    sal_uInt16;
      59             : #else
      60             :      #error "Could not find 16-bit type, add support for your architecture"
      61             : #endif
      62             : 
      63             : #if SAL_TYPES_SIZEOFLONG == 4
      64             :     typedef signed long       sal_Int32;
      65             :     typedef unsigned long     sal_uInt32;
      66             :     #define SAL_PRIdINT32 "ld"
      67             :     #define SAL_PRIuUINT32 "lu"
      68             :     #define SAL_PRIxUINT32 "lx"
      69             :     #define SAL_PRIXUINT32 "lX"
      70             : #elif SAL_TYPES_SIZEOFINT == 4
      71             :     typedef signed int        sal_Int32;
      72             :     typedef unsigned int      sal_uInt32;
      73             :     #define SAL_PRIdINT32 "d"
      74             :     #define SAL_PRIuUINT32 "u"
      75             :     #define SAL_PRIxUINT32 "x"
      76             :     #define SAL_PRIXUINT32 "X"
      77             : #else
      78             :      #error "Could not find 32-bit type, add support for your architecture"
      79             : #endif
      80             : 
      81             : #ifdef _MSC_VER
      82             :     typedef __int64                  sal_Int64;
      83             :     typedef unsigned __int64         sal_uInt64;
      84             : 
      85             :     /*  The following are macros that will add the 64 bit constant suffix. */
      86             :     #define SAL_CONST_INT64(x)       x##i64
      87             :     #define SAL_CONST_UINT64(x)      x##ui64
      88             : 
      89             :     #define SAL_PRIdINT64 "I64d"
      90             :     #define SAL_PRIuUINT64 "I64u"
      91             :     #define SAL_PRIxUINT64 "I64x"
      92             :     #define SAL_PRIXUINT64 "I64X"
      93             : #elif defined (__GNUC__)
      94             :     #if SAL_TYPES_SIZEOFLONG == 8
      95             :         typedef signed long int         sal_Int64;
      96             :         typedef unsigned long int       sal_uInt64;
      97             : 
      98             : 
      99             :         /*  The following are macros that will add the 64 bit constant suffix. */
     100             :         #define SAL_CONST_INT64(x)       x##l
     101             :         #define SAL_CONST_UINT64(x)      x##ul
     102             : 
     103             :         #define SAL_PRIdINT64 "ld"
     104             :         #define SAL_PRIuUINT64 "lu"
     105             :         #define SAL_PRIxUINT64 "lx"
     106             :         #define SAL_PRIXUINT64 "lX"
     107             :     #elif SAL_TYPES_SIZEOFLONGLONG == 8
     108             :         typedef signed long long    sal_Int64;
     109             :         typedef unsigned long long  sal_uInt64;
     110             : 
     111             :         /*  The following are macros that will add the 64 bit constant suffix. */
     112             :         #define SAL_CONST_INT64(x)       x##ll
     113             :         #define SAL_CONST_UINT64(x)      x##ull
     114             : 
     115             :         #define SAL_PRIdINT64 "lld"
     116             :         #define SAL_PRIuUINT64 "llu"
     117             :         #define SAL_PRIxUINT64 "llx"
     118             :         #define SAL_PRIXUINT64 "llX"
     119             :     #else
     120             :         #error "Could not find 64-bit type, add support for your architecture"
     121             :     #endif
     122             : #else
     123             :     #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
     124             : #endif
     125             : 
     126             : /** A legacy synonym for `char`.
     127             : 
     128             :     @deprecated use plain `char` instead.
     129             : */
     130             : typedef char sal_Char;
     131             : 
     132             : /** A legacy synonym for `signed char`.
     133             : 
     134             :     @deprecated use plain `signed char` instead.
     135             : */
     136             : typedef signed char sal_sChar;
     137             : 
     138             : /** A legacy synonym for `unsigned char`.
     139             : 
     140             :     @deprecated use plain `unsigned char` instead.
     141             : */
     142             : typedef unsigned char sal_uChar;
     143             : 
     144             : #if ( defined(SAL_W32) && !defined(__MINGW32__) )
     145             :     // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx
     146             :     // "By default wchar_t is a typedef for unsigned short."
     147             :     // But MinGW has a native wchar_t, and on many places, we cannot deal with
     148             :     // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there.
     149             :     typedef wchar_t             sal_Unicode;
     150             : #else
     151             :     #define SAL_UNICODE_NOTEQUAL_WCHAR_T
     152             :     typedef sal_uInt16          sal_Unicode;
     153             : #endif
     154             : 
     155             : typedef void *                   sal_Handle;
     156             : 
     157             : /* sal_Size should currently be the native width of the platform */
     158             : #if SAL_TYPES_SIZEOFPOINTER == 4
     159             :     typedef sal_uInt32          sal_Size;
     160             :     typedef sal_Int32           sal_sSize;
     161             : #elif SAL_TYPES_SIZEOFPOINTER == 8
     162             :     typedef sal_uInt64          sal_Size;
     163             :     typedef sal_Int64           sal_sSize;
     164             : #else
     165             :     #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
     166             : #endif
     167             : 
     168             : /* sal_PtrDiff holds the result of a pointer subtraction */
     169             : #if SAL_TYPES_SIZEOFPOINTER == 4
     170             :     typedef sal_Int32           sal_PtrDiff;
     171             : #elif SAL_TYPES_SIZEOFPOINTER == 8
     172             :     typedef sal_Int64           sal_PtrDiff;
     173             : #else
     174             :     #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
     175             : #endif
     176             : 
     177             : /* printf-style conversion specification length modifiers for size_t and
     178             :    ptrdiff_t (most platforms support C99, MSC has its own extension) */
     179             : #if defined(_MSC_VER)
     180             :     #define SAL_PRI_SIZET "I"
     181             :     #define SAL_PRI_PTRDIFFT "I"
     182             : #else
     183             :     #define SAL_PRI_SIZET "z"
     184             :     #define SAL_PRI_PTRDIFFT "t"
     185             : #endif
     186             : 
     187             : /* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
     188             :  * pointer to void can be converted to this type and back to a pointer to void and the
     189             :  * result will compare to the original pointer */
     190             : #if SAL_TYPES_SIZEOFPOINTER == 4
     191             :     typedef sal_Int32           sal_IntPtr;
     192             :     typedef sal_uInt32          sal_uIntPtr;
     193             :     #define SAL_PRIdINTPTR SAL_PRIdINT32
     194             :     #define SAL_PRIuUINTPTR SAL_PRIuUINT32
     195             :     #define SAL_PRIxUINTPTR SAL_PRIxUINT32
     196             :     #define SAL_PRIXUINTPTR SAL_PRIXUINT32
     197             : #elif SAL_TYPES_SIZEOFPOINTER == 8
     198             :     typedef sal_Int64           sal_IntPtr;
     199             :     typedef sal_uInt64          sal_uIntPtr;
     200             :     #define SAL_PRIdINTPTR SAL_PRIdINT64
     201             :     #define SAL_PRIuUINTPTR SAL_PRIuUINT64
     202             :     #define SAL_PRIxUINTPTR SAL_PRIxUINT64
     203             :     #define SAL_PRIXUINTPTR SAL_PRIXUINT64
     204             : #else
     205             :     #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
     206             : #endif
     207             : 
     208             : /********************************************************************************/
     209             : /* Useful defines
     210             :  */
     211             : 
     212             : /* The following SAL_MIN_INTn defines codify the assumption that the signed
     213             :  * sal_Int types use two's complement representation.  Defining them as
     214             :  * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
     215             :  * unary minus operator to unsigned quantities.
     216             :  */
     217             : #define SAL_MIN_INT8          ((sal_Int8)   (-0x7F - 1))
     218             : #define SAL_MAX_INT8          ((sal_Int8)   0x7F)
     219             : #define SAL_MAX_UINT8         ((sal_uInt8)  0xFF)
     220             : #define SAL_MIN_INT16         ((sal_Int16)  (-0x7FFF - 1))
     221             : #define SAL_MAX_INT16         ((sal_Int16)  0x7FFF)
     222             : #define SAL_MAX_UINT16        ((sal_uInt16) 0xFFFF)
     223             : #define SAL_MIN_INT32         ((sal_Int32)  (-0x7FFFFFFF - 1))
     224             : #define SAL_MAX_INT32         ((sal_Int32)  0x7FFFFFFF)
     225             : #define SAL_MAX_UINT32        ((sal_uInt32) 0xFFFFFFFF)
     226             : #define SAL_MIN_INT64         ((sal_Int64)  (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
     227             : #define SAL_MAX_INT64         ((sal_Int64)  SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
     228             : #define SAL_MAX_UINT64        ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
     229             : 
     230             : #if SAL_TYPES_SIZEOFPOINTER == 4
     231             : #define SAL_MAX_SSIZE       SAL_MAX_INT32
     232             : #define SAL_MAX_SIZE        SAL_MAX_UINT32
     233             : #elif SAL_TYPES_SIZEOFPOINTER == 8
     234             : #define SAL_MAX_SSIZE       SAL_MAX_INT64
     235             : #define SAL_MAX_SIZE        SAL_MAX_UINT64
     236             : #endif
     237             : 
     238             : #define SAL_MAX_ENUM 0x7fffffff
     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_DLLPUBLIC_RTTI
     251             : #   define SAL_CALL         __cdecl
     252             : #   define SAL_CALL_ELLIPSE __cdecl
     253             : #elif defined SAL_UNX
     254             : #   if defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
     255             : #     if defined(DISABLE_DYNLOADING)
     256             : #       define SAL_DLLPUBLIC_EXPORT  __attribute__ ((visibility("hidden")))
     257             : #       define SAL_JNI_EXPORT        __attribute__ ((visibility("default")))
     258             : #       define SAL_DLLPUBLIC_IMPORT  __attribute__ ((visibility("hidden")))
     259             : #       define SAL_DLLPRIVATE        __attribute__ ((visibility("hidden")))
     260             : #       define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
     261             : #       define SAL_DLLPUBLIC_RTTI
     262             : #     else
     263             : #       define SAL_DLLPUBLIC_EXPORT  __attribute__ ((visibility("default")))
     264             : #       define SAL_JNI_EXPORT        __attribute__ ((visibility("default")))
     265             : #       define SAL_DLLPUBLIC_IMPORT  __attribute__ ((visibility("default")))
     266             : #       define SAL_DLLPRIVATE        __attribute__ ((visibility("hidden")))
     267             : #       define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
     268             : #       if defined __clang__
     269             : #         if __has_attribute(type_visibility)
     270             : #           define SAL_DLLPUBLIC_RTTI  __attribute__ ((type_visibility("default")))
     271             : #         else
     272             : #           define SAL_DLLPUBLIC_RTTI  __attribute__ ((visibility("default")))
     273             : #         endif
     274             : #       else
     275             : #         define SAL_DLLPUBLIC_RTTI
     276             : #       endif
     277             : #     endif
     278             : #   else
     279             : #     define SAL_DLLPUBLIC_EXPORT
     280             : #     define SAL_JNI_EXPORT
     281             : #     define SAL_DLLPUBLIC_IMPORT
     282             : #     define SAL_DLLPRIVATE
     283             : #     define SAL_DLLPUBLIC_TEMPLATE
     284             : #     define SAL_DLLPUBLIC_RTTI
     285             : #   endif
     286             : #   define SAL_CALL
     287             : #   define SAL_CALL_ELLIPSE
     288             : #else
     289             : #   error("unknown platform")
     290             : #endif
     291             : 
     292             : /**
     293             :    Exporting the symbols necessary for exception handling on GCC.
     294             : 
     295             :    These macros are used for inline declarations of exception classes, as in
     296             :    rtl/malformeduriexception.hxx.
     297             : */
     298             : #if defined(__GNUC__) && ! defined(__MINGW32__)
     299             : #   if defined(DISABLE_DYNLOADING)
     300             : #      define SAL_EXCEPTION_DLLPUBLIC_EXPORT __attribute__((visibility("default")))
     301             : #    else
     302             : #      define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
     303             : #    endif
     304             : #    define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
     305             : #else
     306             : #    define SAL_EXCEPTION_DLLPUBLIC_EXPORT
     307             : #    define SAL_EXCEPTION_DLLPRIVATE
     308             : #endif
     309             : 
     310             : /** Use this as markup for functions and methods whose return value must be
     311             :     checked.
     312             : 
     313             :     Compilers that support a construct of this nature will emit a compile
     314             :     time warning on unchecked return value.
     315             : */
     316             : #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
     317             : #   define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
     318             : #else
     319             : #   define SAL_WARN_UNUSED_RESULT
     320             : #endif
     321             : 
     322             : /** Use this for pure virtual classes, e.g. class SAL_NO_VTABLE Foo { ...
     323             :     This hinders the compiler from setting a generic vtable stating that
     324             :     a pure virtual function was called and thus slightly reduces code size.
     325             : */
     326             : #ifdef _MSC_VER
     327             : #   define SAL_NO_VTABLE __declspec(novtable)
     328             : #else
     329             : #   define SAL_NO_VTABLE
     330             : #endif
     331             : 
     332             : #ifdef SAL_W32
     333             : #   pragma pack(push, 8)
     334             : #endif
     335             : 
     336             : /** This is the binary specification of a SAL sequence.
     337             :     <br>
     338             : */
     339             : typedef struct _sal_Sequence
     340             : {
     341             :     /** reference count of sequence<br>
     342             :     */
     343             :     sal_Int32           nRefCount;
     344             :     /** element count<br>
     345             :     */
     346             :     sal_Int32           nElements;
     347             :     /** elements array<br>
     348             :     */
     349             :     char                elements[1];
     350             : } sal_Sequence;
     351             : 
     352             : #define SAL_SEQUENCE_HEADER_SIZE ((sal_Size) offsetof(sal_Sequence,elements))
     353             : 
     354             : #if defined( SAL_W32)
     355             : #pragma pack(pop)
     356             : #endif
     357             : 
     358             : #if defined __cplusplus
     359             : 
     360             : /** Nothrow specification for C functions.
     361             : 
     362             :     This is a macro so it can expand to nothing in C code.
     363             : */
     364             : #define SAL_THROW_EXTERN_C() throw ()
     365             : 
     366             : #else
     367             : 
     368             : #define SAL_THROW_EXTERN_C()
     369             : 
     370             : #endif
     371             : 
     372             : #ifdef __cplusplus
     373             : }
     374             : #endif /* __cplusplus */
     375             : 
     376             : #ifdef __cplusplus
     377             : 
     378             : enum __sal_NoAcquire
     379             : {
     380             :     /** definition of a no acquire enum for ctors
     381             :     */
     382             :     SAL_NO_ACQUIRE
     383             : };
     384             : 
     385             : namespace com { namespace sun { namespace star { } } }
     386             : 
     387             : /** short-circuit extra-verbose API namespaces
     388             : 
     389             :  @since LibreOffice 4.0
     390             : */
     391             : namespace css = ::com::sun::star;
     392             : 
     393             : /** C++11 "= delete" feature.
     394             : 
     395             :     With HAVE_CXX11_DELETE, calling a deleted function will cause a compile-time
     396             :     error, while otherwise it will only cause a link-time error as the declared
     397             :     function is not defined.
     398             : 
     399             :     @since LibreOffice 4.1
     400             : */
     401             : #if HAVE_CXX11_DELETE
     402             : #define SAL_DELETED_FUNCTION = delete
     403             : #else
     404             : #define SAL_DELETED_FUNCTION
     405             : #endif
     406             : 
     407             : /** C++11 "override" feature.
     408             : 
     409             :     With HAVE_CXX11_OVERRIDE, force the method to override a existing method in
     410             :     parent, error out if the method with the correct signature does not exist.
     411             : 
     412             :     @since LibreOffice 4.1
     413             : */
     414             : #if HAVE_CXX11_OVERRIDE
     415             : #define SAL_OVERRIDE override
     416             : #else
     417             : #define SAL_OVERRIDE
     418             : #endif
     419             : 
     420             : /** C++11 "final" feature.
     421             : 
     422             :     With HAVE_CXX11_FINAL, mark a class as non-derivable or a method as non-overridable.
     423             : 
     424             :     @since LibreOffice 4.1
     425             : */
     426             : #if HAVE_CXX11_FINAL
     427             : #define SAL_FINAL final
     428             : #else
     429             : #define SAL_FINAL
     430             : #endif
     431             : 
     432             : /** C++11 "constexpr" feature.
     433             : 
     434             :     @since LibreOffice 5.0
     435             : */
     436             : #if HAVE_CXX11_CONSTEXPR
     437             : #define SAL_CONSTEXPR constexpr
     438             : #else
     439             : #define SAL_CONSTEXPR
     440             : #endif
     441             : 
     442             : #endif /* __cplusplus */
     443             : 
     444             : #ifdef __cplusplus
     445             : 
     446             : namespace sal {
     447             : 
     448             : /**
     449             :    A static_cast between integral types, to avoid C++ compiler warnings.
     450             : 
     451             :    In C++ source code, use sal::static_int_cast<T>(n) instead of
     452             :    static_cast<T>(n) whenever a compiler warning about integral type problems
     453             :    shall be silenced.  That way, source code that needs to be modified when the
     454             :    type of any of the expressions involved in the compiler warning is changed
     455             :    can be found more easily.
     456             : 
     457             :    Both template arguments T1 and T2 must be integral types.
     458             : */
     459  3336207108 : template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
     460  3336207108 :     return static_cast< T1 >(n);
     461             : }
     462             : 
     463             : }
     464             : 
     465             : #else /* __cplusplus */
     466             : 
     467             : /**
     468             :    A cast between integer types, to avoid C compiler warnings.
     469             : 
     470             :    In C source code, use SAL_INT_CAST(type, expr) instead of ((type) (expr))
     471             :    whenever a compiler warning about integer type problems shall be silenced.
     472             :    That way, source code that needs to be modified when the type of any of the
     473             :    expressions involved in the compiler warning is changed can be found more
     474             :    easily.
     475             : 
     476             :    The argument 'type' must be an integer type and the argument 'expr' must be
     477             :    an integer expression.  Both arguments are evaluated exactly once.
     478             : */
     479             : #define SAL_INT_CAST(type, expr) ((type) (expr))
     480             : 
     481             : #endif /* __cplusplus */
     482             : 
     483             : /**
     484             :     Use as follows:
     485             :         SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);
     486             : */
     487             : 
     488             : #if HAVE_GCC_DEPRECATED_MESSAGE
     489             : #    define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
     490             : #elif (__GNUC__)
     491             : #    define SAL_DEPRECATED(message) __attribute__((deprecated))
     492             : #elif defined(_MSC_VER)
     493             : #    define SAL_DEPRECATED(message) __declspec(deprecated(message))
     494             : #else
     495             : #    define SAL_DEPRECATED(message)
     496             : #endif
     497             : 
     498             : /**
     499             :    This macro is used to tag interfaces that are deprecated for both
     500             :    internal and external API users, but where we are still writing
     501             :    out the internal usage. Ultimately these should be replaced by
     502             :    SAL_DEPRECATED, and then removed.
     503             : 
     504             :    Use as follows:
     505             :         SAL_DEPRECATED_INTERNAL("Dont use, its evil.") void doit(int nPara);
     506             :  */
     507             : #ifdef LIBO_INTERNAL_ONLY
     508             : #    define SAL_DEPRECATED_INTERNAL(message)
     509             : #else
     510             : #    define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
     511             : #endif
     512             : 
     513             : /**
     514             :     Use as follows:
     515             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     516             :         \::std::auto_ptr<X> ...
     517             :         SAL_WNODEPRECATED_DECLARATIONS_POP
     518             : */
     519             : 
     520             : #if HAVE_GCC_PRAGMA_OPERATOR
     521             : #define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
     522             :     _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
     523             :     _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
     524             : #define SAL_WNODEPRECATED_DECLARATIONS_POP \
     525             :     _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
     526             : #else
     527             : #   define SAL_WNODEPRECATED_DECLARATIONS_PUSH
     528             : #   define SAL_WNODEPRECATED_DECLARATIONS_POP
     529             : #endif
     530             : 
     531             : /**
     532             :    Use as follows:
     533             : 
     534             :    SAL_WNOUNREACHABLE_CODE_PUSH
     535             : 
     536             :    function definition
     537             : 
     538             :    SAL_WNOUNREACHABLE_CODE_POP
     539             : 
     540             :    Useful in cases where the compiler is "too clever" like when doing
     541             :    link-time code generation, and noticing that a called function
     542             :    always throws, and fixing the problem cleanly so that it produceds
     543             :    no warnings in normal non-LTO compilations either is not easy.
     544             : 
     545             : */
     546             : 
     547             : #ifdef _MSC_VER
     548             : #define SAL_WNOUNREACHABLE_CODE_PUSH \
     549             :     __pragma(warning(push)) \
     550             :     __pragma(warning(disable:4702)) \
     551             :     __pragma(warning(disable:4722))
     552             : #define SAL_WNOUNREACHABLE_CODE_POP \
     553             :     __pragma(warning(pop))
     554             : #else
     555             : /* Add definitions for GCC and Clang if needed */
     556             : #define SAL_WNOUNREACHABLE_CODE_PUSH
     557             : #define SAL_WNOUNREACHABLE_CODE_POP
     558             : #endif
     559             : 
     560             : /** Annotate unused but required C++ function parameters.
     561             : 
     562             :     An unused parameter is required if the function needs to adhere to a given
     563             :     type (e.g., if its address is assigned to a function pointer of a specific
     564             :     type, or if it is called from template code).  This annotation helps static
     565             :     analysis tools suppress false warnings.  In the case of virtual functions
     566             :     (where unused required parameters are common, too), the annotation is not
     567             :     required (as static analysis tools can themselves derive the information
     568             :     whether a function is virtual).
     569             : 
     570             :     Use the annotation in function definitions like
     571             : 
     572             :       void f(SAL_UNUSED_PARAMETER int) {}
     573             : 
     574             :     C does not allow unnamed parameters, anyway, so a function definition like
     575             :     the above needs to be written there as
     576             : 
     577             :       void f(int dummy) { (void) dummy; / * avoid warnings * / }
     578             : 
     579             :     without a SAL_UNUSED_PARAMETER annotation.
     580             : 
     581             :     @since LibreOffice 3.6
     582             :  */
     583             : #if defined __cplusplus
     584             : #if defined __GNUC__
     585             : #define SAL_UNUSED_PARAMETER __attribute__ ((unused))
     586             : #else
     587             : #define SAL_UNUSED_PARAMETER
     588             : #endif
     589             : #endif
     590             : 
     591             : /**
     592             : 
     593             :  Annotate classes where a compiler should warn if an instance is unused.
     594             : 
     595             :  The compiler cannot warn about unused instances if they have non-trivial
     596             :  or external constructors or destructors. Classes marked with SAL_WARN_UNUSED
     597             :  will be warned about.
     598             : 
     599             :  @since LibreOffice 4.0
     600             : 
     601             : */
     602             : 
     603             : #if HAVE_GCC_ATTRIBUTE_WARN_UNUSED
     604             : #define SAL_WARN_UNUSED __attribute__((warn_unused))
     605             : #elif defined __clang__
     606             : #define SAL_WARN_UNUSED __attribute__((annotate("lo_warn_unused")))
     607             : #else
     608             : #define SAL_WARN_UNUSED
     609             : #endif
     610             : 
     611             : #endif // INCLUDED_SAL_TYPES_H
     612             : 
     613             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11