Point Cloud Library (PCL)  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
pcl_macros.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00035 #ifndef PCL_MACROS_H_
00036 #define PCL_MACROS_H_
00037 
00038 #include <boost/cstdint.hpp>
00039 
00040 namespace pcl
00041 {
00042   using boost::uint8_t;
00043   using boost::int8_t;
00044   using boost::int16_t;
00045   using boost::uint16_t;
00046   using boost::int32_t;
00047   using boost::uint32_t;
00048   using boost::int64_t;
00049   using boost::uint64_t;
00050 }
00051 
00052 #if defined __INTEL_COMPILER
00053   #pragma warning disable 2196 2536 279
00054 #endif
00055 
00056 #if defined _MSC_VER
00057   #pragma warning (disable : 4521)
00058 #endif
00059 
00060 #include <iostream>
00061 #include <stdarg.h>
00062 #include <stdio.h>
00063 
00064 // MSCV doesn't have std::{isnan,isfinite}
00065 #if defined _WIN32 && defined _MSC_VER
00066 
00067 // Stupid. This should be removed when all the PCL dependencies have min/max fixed.
00068 #ifndef NOMINMAX
00069 # define NOMINMAX
00070 #endif
00071 
00072 # define pcl_isnan(x)    _isnan(x)
00073 # define pcl_isfinite(x) (_finite(x) != 0)
00074 # define pcl_isinf(x)    (_finite(x) == 0)
00075 
00076 # define __PRETTY_FUNCTION__ __FUNCTION__
00077 # define __func__ __FUNCTION__
00078 
00079 #elif ANDROID
00080 // Use the math.h macros
00081 # include <math.h>
00082 # define pcl_isnan(x)    isnan(x)
00083 # define pcl_isfinite(x) isfinite(x)
00084 # define pcl_isinf(x)    isinf(x)
00085 
00086 #elif _GLIBCXX_USE_C99_MATH
00087 // Are the C++ cmath functions enabled?
00088 # include <cmath>
00089 # define pcl_isnan(x)    std::isnan(x)
00090 # define pcl_isfinite(x) std::isfinite(x)
00091 # define pcl_isinf(x)    std::isinf(x)
00092 
00093 #elif __PATHCC__
00094 # include <cmath>
00095 # include <stdio.h>
00096 template <typename T> int
00097 pcl_isnan (T &val)
00098 {
00099   return (val != val);
00100 }
00101 //# define pcl_isnan(x)    std::isnan(x)
00102 # define pcl_isfinite(x) std::isfinite(x)
00103 # define pcl_isinf(x)    std::isinf(x)
00104 
00105 #else
00106 // Use the math.h macros
00107 # include <math.h>
00108 # define pcl_isnan(x)    isnan(x)
00109 # define pcl_isfinite(x) isfinite(x)
00110 # define pcl_isinf(x)    isinf(x)
00111 
00112 #endif
00113 
00114 // Windows doesn't like M_PI.
00115 #ifndef M_PI
00116 #define M_PI 3.14159265358979323846
00117 #endif
00118 
00119 #ifndef M_E
00120 #define M_E 2.7182818284590452354
00121 #endif
00122 
00123 #ifndef M_LN2
00124 #define M_LN2 0.693147180559945309417
00125 #endif
00126 
00127 #ifndef DEG2RAD
00128 #define DEG2RAD(x) ((x)*0.017453293)
00129 #endif
00130 
00131 #ifndef RAD2DEG
00132 #define RAD2DEG(x) ((x)*57.29578)
00133 #endif
00134 
00138 #include <math.h>
00139 __inline double 
00140 pcl_round (double number)
00141 {
00142   return (number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5));
00143 }
00144 __inline float 
00145 pcl_round (float number)
00146 {
00147   return (number < 0.0f ? ceil(number - 0.5f) : floor(number + 0.5f));
00148 }
00149 
00150 #define pcl_lrint(x) ((long int) pcl_round(x))
00151 #define pcl_lrintf(x) ((long int) pcl_round(x))
00152 
00153 #ifdef WIN32
00154 #define pcl_sleep(x) Sleep(1000*(x))
00155 #else
00156 #define pcl_sleep(x) sleep(x)
00157 #endif
00158 
00159 #ifndef PVAR
00160   #define PVAR(s) \
00161     #s << " = " << (s) << std::flush
00162 #endif
00163 #ifndef PVARN
00164 #define PVARN(s) \
00165   #s << " = " << (s) << "\n"
00166 #endif
00167 #ifndef PVARC
00168 #define PVARC(s) \
00169   #s << " = " << (s) << ", " << std::flush
00170 #endif
00171 #ifndef PVARS
00172 #define PVARS(s) \
00173   #s << " = " << (s) << " " << std::flush
00174 #endif
00175 #ifndef PVARA
00176 #define PVARA(s) \
00177   #s << " = " << RAD2DEG(s) << "deg" << std::flush
00178 #endif
00179 #ifndef PVARAN
00180 #define PVARAN(s) \
00181   #s << " = " << RAD2DEG(s) << "deg\n"
00182 #endif
00183 #ifndef PVARAC
00184 #define PVARAC(s) \
00185   #s << " = " << RAD2DEG(s) << "deg, " << std::flush
00186 #endif
00187 #ifndef PVARAS
00188 #define PVARAS(s) \
00189   #s << " = " << RAD2DEG(s) << "deg " << std::flush
00190 #endif
00191 
00192 #define FIXED(s) \
00193   std::fixed << s << std::resetiosflags(std::ios_base::fixed)
00194 
00195 #ifndef ERASE_STRUCT
00196 #define ERASE_STRUCT(var) memset(&var, 0, sizeof(var))
00197 #endif
00198 
00199 #ifndef ERASE_ARRAY
00200 #define ERASE_ARRAY(var, size) memset(var, 0, size*sizeof(*var))
00201 #endif
00202 
00203 #ifndef SET_ARRAY
00204 #define SET_ARRAY(var, value, size) {for (int i=0; i<(int)size; ++i) var[i]=value;}
00205 #endif
00206 
00207 /* //This is copy/paste from http://gcc.gnu.org/wiki/Visibility */
00208 /* #if defined _WIN32 || defined __CYGWIN__ */
00209 /*   #ifdef BUILDING_DLL */
00210 /*     #ifdef __GNUC__ */
00211 /* #define DLL_PUBLIC __attribute__((dllexport)) */
00212 /*     #else */
00213 /* #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax. */
00214 /*     #endif */
00215 /*   #else */
00216 /*     #ifdef __GNUC__ */
00217 /* #define DLL_PUBLIC __attribute__((dllimport)) */
00218 /*     #else */
00219 /* #define DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also supports this syntax. */
00220 /*     #endif */
00221 /*   #endif */
00222 /*   #define DLL_LOCAL */
00223 /* #else */
00224 /*   #if __GNUC__ >= 4 */
00225 /* #define DLL_PUBLIC __attribute__ ((visibility("default"))) */
00226 /* #define DLL_LOCAL  __attribute__ ((visibility("hidden"))) */
00227 /*   #else */
00228 /*     #define DLL_PUBLIC */
00229 /*     #define DLL_LOCAL */
00230 /*   #endif */
00231 /* #endif */
00232 
00233 #ifndef PCL_EXTERN_C
00234     #ifdef __cplusplus
00235         #define PCL_EXTERN_C extern "C"
00236     #else
00237         #define PCL_EXTERN_C
00238     #endif
00239 #endif
00240 
00241 #if defined WIN32 || defined _WIN32 || defined WINCE || defined __MINGW32__
00242     #ifdef PCLAPI_EXPORTS
00243         #define PCL_EXPORTS __declspec(dllexport)
00244     #else
00245         #define PCL_EXPORTS
00246     #endif
00247 #else
00248     #define PCL_EXPORTS
00249 #endif
00250 
00251 #if defined WIN32 || defined _WIN32
00252     #define PCL_CDECL __cdecl
00253     #define PCL_STDCALL __stdcall
00254 #else
00255     #define PCL_CDECL
00256     #define PCL_STDCALL
00257 #endif
00258 
00259 #ifndef PCLAPI
00260     #define PCLAPI(rettype) PCL_EXTERN_C PCL_EXPORTS rettype PCL_CDECL
00261 #endif
00262 
00263 // Macro to deprecate old functions
00264 //
00265 // Usage:
00266 // don't use me any more
00267 // PCL_DEPRECATED(void OldFunc(int a, float b), "Use newFunc instead, this functions will be gone in the next major release");
00268 // use me instead
00269 // void NewFunc(int a, double b);
00270 
00271 // gcc supports this starting from 4.5 : http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43666
00272 #ifdef __GNUC__
00273 #define GCC_VERSION (__GNUC__ * 10000 \
00274     + __GNUC_MINOR__ * 100 \
00275     + __GNUC_PATCHLEVEL__)
00276 #if GCC_VERSION < 40500
00277 #define PCL_DEPRECATED(func, message) func __attribute__ ((deprecated))
00278 #else
00279 #define PCL_DEPRECATED(func, message) func __attribute__ ((deprecated(message)))
00280 #endif
00281 
00282 #elif defined(_MSC_VER)
00283 #define PCL_DEPRECATED(func, message) __declspec(deprecated(message)) func
00284 #else
00285 #pragma message("WARNING: You need to implement PCL_DEPRECATED for this compiler")
00286 #define PCL_DEPRECATED(func) func
00287 #endif
00288 
00289 #endif  //#ifndef PCL_MACROS_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines