Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
Compiler.hpp
Go to the documentation of this file.
00001 /** \file   Compiler.hpp
00002  *  \author Jason Kraftcheck
00003  *  \date   2010-12-16
00004  *
00005  * Provide pre-processor macros for compiler-specific features.  All
00006  * defined macros should expand to nothing if not supported by the
00007  * compiler.
00008  */
00009 
00010 #ifndef moab_COMPILER_HPP
00011 #define moab_COMPILER_HPP
00012 
00013 #ifdef IS_BUILDING_MB
00014 
00015 /**\defgroup PRIVCOMP Private Compiler-Specifc Pre-Processor Macros */
00016 /*@{*/
00017 
00018 /**\def __restrict__
00019  *\brief Provide functionality similar to C99 \c restrict keyword
00020  *
00021  * Tell the compiler that a pointer is not aliased.  This means that
00022  * programmer guarantees that no other pointer will be used to reference
00023  * memory that is referenced through the designated pointer unless it
00024  * is obivous to the compiler in the relevant function.  A typical use
00025  * for this is to specify that two pointer arguments to a function will
00026  * never be used to reference overlapping memory.  For example:
00027  *\code
00028  *  void* memcpy(void* __restrict__ dest, const void* __restrict__ src, size_t len);
00029  *\endcode
00030  * Says that the memory locations indicated by the \c dest and \c src pointers
00031  * will never be used to reference overlapping memory, including offsets up to
00032  * \c len.
00033  *
00034  * Notifying the compiler about lack of pointer aliasing allows it to make
00035  * better optimizations.  However, the behavior is undefined (and probably
00036  * broken in platform-specific ways) if designated pointers are aliased.
00037  */
00038 #ifdef __cplusplus
00039 #if !defined __GNUC__ || __GNUC__ < 4 || __GNUC_MINOR__ < 5
00040 #define __restrict__
00041 #endif
00042 #endif
00043 
00044 /*@}*/
00045 
00046 #endif
00047 
00048 /**\defgroup PUBCOMP Public Compiler-Specifc Pre-Processor Macros */
00049 /*@{*/
00050 
00051 /**\def PRINT_FORMAT(start)
00052  *\brief Give a hint to the compiler the function is like \c printf
00053  *
00054  * Tell the compiler that the function involves a printf-style format
00055  * string and varargs list.  This gives the compiler the opportunity
00056  * to warn if the argument types do not match the format string.
00057  * This macro should be inluded after the complete function declaration,
00058  * but before the closing semi-colon.
00059  *
00060  *\param START The position of the format string in the argument list, where
00061  *             the first argument is 1.
00062  *\NOTE This macro is designed to be used with member functions of C++ classes,
00063  *      and therefore explicitly accounts for the implicit \c this pointer
00064  *      in the argument list.  It will not work correctly with static or
00065  *      non-member functions.
00066  *\NOTE This macro assumes that the arguments referenced in the format string
00067  *      begin immediately after the format string itself.
00068  */
00069 #ifdef __GNUC__
00070 #define MB_PRINTF( START ) __attribute__( ( format( printf, ( START ) + 1, ( START ) + 2 ) ) )
00071 #else
00072 #define MB_PRINTF( START )
00073 #endif
00074 
00075 /**\def MB_DLL_EXPORT
00076  *\brief Declare a function or class to be visible in shared library.
00077  */
00078 /**\def MB_DLL_HIDDEN
00079  *\brief Declare a function or class to be internal to a shared library.
00080  */
00081 #if defined _MSC_VER || defined __CYGWIN__ || defined __MINGW32__ || defined __MINGW64__ || defined _WIN32
00082 #if !defined IS_BUILDING_MB || !defined MB_EXPORTS
00083 #define MB_DLL_EXPORT __dllspec( dllexport )
00084 #elif !defined MB_WIN_DLL
00085 #define MB_DLL_EXPORT __dllspec( dllimport )
00086 #else
00087 #define MB_DLL_EXPORT
00088 #endif
00089 #define MB_DLL_HIDDEN
00090 #elif defined __GNUC__ && __GNUC__ > 3
00091 #define MB_DLL_EXPORT __attribute__( ( visibility( "default" ) ) )
00092 #define MB_DLL_HIDDEN __attribute__( ( visibility( "hidden" ) ) )
00093 #else
00094 #define MB_DLL_EXPORT
00095 #define MB_DLL_HIDDEN
00096 #endif
00097 
00098 /**\def MB_DEPRECATED
00099  *\brief Mark function or API as deprecated
00100  */
00101 #if defined( __GNUC__ ) && ( 1000 * __GNUC__ + __GNUC_MINOR__ ) > 3000
00102 #define MB_DEPRECATED __attribute__( ( __deprecated__ ) )
00103 #else
00104 #define MB_DEPRECATED
00105 #endif
00106 
00107 /*@}*/
00108 
00109 #endif  // moab_COMPILER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines