Main MRPT website > C++ reference for MRPT 1.5.7
Namespaces | Macros | Functions
mrpt_macros.h File Reference
#include <mrpt/base/link_pragmas.h>
#include <sstream>
#include <stdexcept>
Include dependency graph for mrpt_macros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 mrpt
 This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
 

Macros

#define MRPT_CHECK_GCC_VERSION(major, minor)   0
 MRPT_CHECK_GCC_VERSION(MAJ,MIN) More...
 
#define MRPT_VISUALC_VERSION(major)   0
 MRPT_CHECK_VISUALC_VERSION(Version) Version=8 for 2005, 9=2008, 10=2010, 11=2012, 12=2013, 14=2015. More...
 
#define MRPT_CHECK_VISUALC_VERSION(major)   0
 
#define __has_feature(x)   0
 
#define __has_extension   __has_feature
 
#define MRPT_HAS_CXX11   0
 Does the compiler support C++11? More...
 
#define MRPT_OVERRIDE
 C++11 "override" for virtuals: More...
 
#define MRPT_DELETED_FUNC
 C++11 deleted function declarations. More...
 
#define MRPT_NO_THROWS   throw()
 C++11 noexcept: Used after member declarations. More...
 
#define MRPT_HAS_UNIQUE_PTR   0
 C++11 unique_ptr<> More...
 
#define MRPT_DEPRECATED(msg)
 Usage: MRPT_DEPRECATED("Use XX instead") void myFunc(double);. More...
 
#define MRPT_DO_PRAGMA(x)
 Declare MRPT_TODO(message)
More...
 
#define MRPT_MSG_PRAGMA(_msg)
 
#define MRPT_WARNING(x)   MRPT_MSG_PRAGMA("Warning: " x)
 
#define MRPT_TODO(x)   MRPT_MSG_PRAGMA("TODO: " x)
 
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_scanf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_ALIGN16
 
#define MRPT_ALIGN32
 
#define __CURRENT_FUNCTION_NAME__   __PRETTY_FUNCTION__
 A macro for obtaining the name of the current function:
More...
 
#define THROW_EXCEPTION(msg)
 
#define THROW_EXCEPTION_FMT(_FORMAT_STRING, ...)    THROW_EXCEPTION(mrpt::format(_FORMAT_STRING,__VA_ARGS__))
 
#define THROW_TYPED_EXCEPTION(msg, exceptionClass)
 Defines a unified way of reporting exceptions of type different than "std::exception". More...
 
#define THROW_TYPED_EXCEPTION_FMT(exceptionClass, _FORMAT_STRING, ...)    THROW_TYPED_EXCEPTION(mrpt::format(_FORMAT_STRING,__VA_ARGS__), exceptionClass)
 
#define THROW_STACKED_EXCEPTION(e)
 
#define THROW_STACKED_EXCEPTION_CUSTOM_MSG1(e, msg)
 
#define THROW_STACKED_EXCEPTION_CUSTOM_MSG2(e, stuff, param1)
 
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)   THROW_EXCEPTION(mrpt::format("Cannot parse object: unknown serialization version number: '%i'",static_cast<int>(__V)))
 For use in CSerializable implementations. More...
 
#define ASSERTMSG_(f, __ERROR_MSG)   { }
 
#define ASSERT_(f)   { }
 
#define MRPT_CHECK_NORMAL_NUMBER(val)   { }
 
#define MRPT_COMPILE_TIME_ASSERT(f)   { }
 
#define ASSERT_EQUAL_(__A, __B)   { }
 
#define ASSERT_NOT_EQUAL_(__A, __B)   { }
 
#define ASSERT_BELOW_(__A, __B)   { }
 
#define ASSERT_ABOVE_(__A, __B)   { }
 
#define ASSERT_BELOWEQ_(__A, __B)   { }
 
#define ASSERT_ABOVEEQ_(__A, __B)   { }
 
#define ASSERT_FILE_EXISTS_(FIL)   { }
 
#define ASSERT_DIRECTORY_EXISTS_(DIR)   { }
 
#define ASSERTDEB_(f)   { }
 Defines an assertion mechanism - only when compiled in debug. More...
 
#define ASSERTDEBMSG_(f, __ERROR_MSG)   { }
 
#define MRPT_UNUSED_PARAM(a)   (void)(a)
 Can be used to avoid "not used parameters" warnings from the compiler. More...
 
#define MRPT_TRY_START
 
#define MRPT_TRY_END
 
#define MRPT_TRY_END_WITH_CLEAN_UP(stuff)
 
#define MRPT_PROFILE_FUNC_START
 
#define MRPT_START
 
#define MRPT_END    MRPT_TRY_END
 
#define MRPT_END_WITH_CLEAN_UP(stuff)    MRPT_TRY_END_WITH_CLEAN_UP(stuff)
 
#define M_2PI   6.283185307179586476925286766559
 
#define M_PIf   3.14159265358979f
 
#define M_2PIf   6.28318530717959f
 
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_scanf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_FORCE_INLINE   inline
 Tells the compiler we really want to inline that function. More...
 
#define PRIuSIZE   zu
 Format specifier for size_t variables in a OS-independent, processor architecture-independent way. More...
 
#define QUOTE(name)   #name
 
#define STR(macro)   QUOTE(macro)
 
#define USIZE_STR   STR(PRIuSIZE)
 

Functions

std::string BASE_IMPEXP mrpt::format (const char *fmt,...) MRPT_printf_format_check(1
 A std::string version of C sprintf. More...
 

Macro Definition Documentation

◆ __CURRENT_FUNCTION_NAME__

#define __CURRENT_FUNCTION_NAME__   __PRETTY_FUNCTION__

A macro for obtaining the name of the current function:

Definition at line 146 of file mrpt_macros.h.

◆ __has_extension

#define __has_extension   __has_feature

Definition at line 43 of file mrpt_macros.h.

◆ __has_feature

#define __has_feature (   x)    0

Definition at line 40 of file mrpt_macros.h.

◆ ASSERT_

#define ASSERT_ (   f)    { }

Definition at line 278 of file mrpt_macros.h.

◆ ASSERT_ABOVE_

#define ASSERT_ABOVE_ (   __A,
  __B 
)    { }

Definition at line 284 of file mrpt_macros.h.

◆ ASSERT_ABOVEEQ_

#define ASSERT_ABOVEEQ_ (   __A,
  __B 
)    { }

Definition at line 286 of file mrpt_macros.h.

◆ ASSERT_BELOW_

#define ASSERT_BELOW_ (   __A,
  __B 
)    { }

Definition at line 283 of file mrpt_macros.h.

◆ ASSERT_BELOWEQ_

#define ASSERT_BELOWEQ_ (   __A,
  __B 
)    { }

Definition at line 285 of file mrpt_macros.h.

◆ ASSERT_DIRECTORY_EXISTS_

#define ASSERT_DIRECTORY_EXISTS_ (   DIR)    { }

Definition at line 289 of file mrpt_macros.h.

◆ ASSERT_EQUAL_

#define ASSERT_EQUAL_ (   __A,
  __B 
)    { }

Definition at line 281 of file mrpt_macros.h.

◆ ASSERT_FILE_EXISTS_

#define ASSERT_FILE_EXISTS_ (   FIL)    { }

Definition at line 288 of file mrpt_macros.h.

◆ ASSERT_NOT_EQUAL_

#define ASSERT_NOT_EQUAL_ (   __A,
  __B 
)    { }

Definition at line 282 of file mrpt_macros.h.

◆ ASSERTDEB_

#define ASSERTDEB_ (   f)    { }

Defines an assertion mechanism - only when compiled in debug.

Note
Do NOT put code that must be always executed inside this statement, but just comparisons. This is because users might require ASSERT_'s to be ignored for optimized releases.
See also
MRPT_TRY_START, MRPT_TRY_END

Definition at line 300 of file mrpt_macros.h.

◆ ASSERTDEBMSG_

#define ASSERTDEBMSG_ (   f,
  __ERROR_MSG 
)    { }

Definition at line 301 of file mrpt_macros.h.

◆ ASSERTMSG_

#define ASSERTMSG_ (   f,
  __ERROR_MSG 
)    { }

Definition at line 277 of file mrpt_macros.h.

◆ M_2PI

#define M_2PI   6.283185307179586476925286766559

Definition at line 380 of file mrpt_macros.h.

◆ M_2PIf

#define M_2PIf   6.28318530717959f

Definition at line 384 of file mrpt_macros.h.

◆ M_PIf

#define M_PIf   3.14159265358979f

Definition at line 383 of file mrpt_macros.h.

◆ MRPT_ALIGN16

#define MRPT_ALIGN16

Definition at line 138 of file mrpt_macros.h.

◆ MRPT_ALIGN32

#define MRPT_ALIGN32

Definition at line 139 of file mrpt_macros.h.

◆ MRPT_CHECK_GCC_VERSION

#define MRPT_CHECK_GCC_VERSION (   major,
  minor 
)    0

MRPT_CHECK_GCC_VERSION(MAJ,MIN)

Definition at line 21 of file mrpt_macros.h.

◆ MRPT_CHECK_NORMAL_NUMBER

#define MRPT_CHECK_NORMAL_NUMBER (   val)    { }

Definition at line 279 of file mrpt_macros.h.

◆ MRPT_CHECK_VISUALC_VERSION

#define MRPT_CHECK_VISUALC_VERSION (   major)    0

Definition at line 27 of file mrpt_macros.h.

◆ MRPT_COMPILE_TIME_ASSERT

#define MRPT_COMPILE_TIME_ASSERT (   f)    { }

Definition at line 280 of file mrpt_macros.h.

◆ MRPT_DELETED_FUNC

#define MRPT_DELETED_FUNC

C++11 deleted function declarations.

Definition at line 65 of file mrpt_macros.h.

◆ MRPT_DEPRECATED

#define MRPT_DEPRECATED (   msg)

Usage: MRPT_DEPRECATED("Use XX instead") void myFunc(double);.

Definition at line 95 of file mrpt_macros.h.

◆ MRPT_DO_PRAGMA

#define MRPT_DO_PRAGMA (   x)

Declare MRPT_TODO(message)

Definition at line 110 of file mrpt_macros.h.

◆ MRPT_END

#define MRPT_END    MRPT_TRY_END

Definition at line 370 of file mrpt_macros.h.

◆ MRPT_END_WITH_CLEAN_UP

#define MRPT_END_WITH_CLEAN_UP (   stuff)     MRPT_TRY_END_WITH_CLEAN_UP(stuff)

Definition at line 373 of file mrpt_macros.h.

◆ MRPT_FORCE_INLINE

#define MRPT_FORCE_INLINE   inline

Tells the compiler we really want to inline that function.

Definition at line 411 of file mrpt_macros.h.

◆ MRPT_HAS_CXX11

#define MRPT_HAS_CXX11   0

Does the compiler support C++11?

Definition at line 51 of file mrpt_macros.h.

◆ MRPT_HAS_UNIQUE_PTR

#define MRPT_HAS_UNIQUE_PTR   0

C++11 unique_ptr<>

Definition at line 79 of file mrpt_macros.h.

◆ MRPT_MSG_PRAGMA

#define MRPT_MSG_PRAGMA (   _msg)

Definition at line 111 of file mrpt_macros.h.

◆ MRPT_NO_THROWS

#define MRPT_NO_THROWS   throw()

C++11 noexcept: Used after member declarations.

Definition at line 72 of file mrpt_macros.h.

◆ MRPT_OVERRIDE

#define MRPT_OVERRIDE

C++11 "override" for virtuals:

Definition at line 58 of file mrpt_macros.h.

◆ MRPT_printf_format_check [1/2]

#define MRPT_printf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 396 of file mrpt_macros.h.

◆ MRPT_printf_format_check [2/2]

#define MRPT_printf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 396 of file mrpt_macros.h.

◆ MRPT_PROFILE_FUNC_START

#define MRPT_PROFILE_FUNC_START

Definition at line 359 of file mrpt_macros.h.

◆ MRPT_scanf_format_check [1/2]

#define MRPT_scanf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 403 of file mrpt_macros.h.

◆ MRPT_scanf_format_check [2/2]

#define MRPT_scanf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 403 of file mrpt_macros.h.

◆ MRPT_START

#define MRPT_START
Value:
MRPT_PROFILE_FUNC_START \
MRPT_TRY_START

Definition at line 366 of file mrpt_macros.h.

◆ MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION

#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION (   __V)    THROW_EXCEPTION(mrpt::format("Cannot parse object: unknown serialization version number: '%i'",static_cast<int>(__V)))

For use in CSerializable implementations.

Definition at line 217 of file mrpt_macros.h.

◆ MRPT_TODO

#define MRPT_TODO (   x)    MRPT_MSG_PRAGMA("TODO: " x)

Definition at line 115 of file mrpt_macros.h.

◆ MRPT_TRY_END

#define MRPT_TRY_END

Definition at line 352 of file mrpt_macros.h.

◆ MRPT_TRY_END_WITH_CLEAN_UP

#define MRPT_TRY_END_WITH_CLEAN_UP (   stuff)

Definition at line 353 of file mrpt_macros.h.

◆ MRPT_TRY_START

#define MRPT_TRY_START

Definition at line 351 of file mrpt_macros.h.

◆ MRPT_UNUSED_PARAM

#define MRPT_UNUSED_PARAM (   a)    (void)(a)

Can be used to avoid "not used parameters" warnings from the compiler.

Definition at line 307 of file mrpt_macros.h.

◆ MRPT_VISUALC_VERSION

#define MRPT_VISUALC_VERSION (   major)    0

MRPT_CHECK_VISUALC_VERSION(Version) Version=8 for 2005, 9=2008, 10=2010, 11=2012, 12=2013, 14=2015.

Definition at line 26 of file mrpt_macros.h.

◆ MRPT_WARNING

#define MRPT_WARNING (   x)    MRPT_MSG_PRAGMA("Warning: " x)

Definition at line 114 of file mrpt_macros.h.

◆ PRIuSIZE

#define PRIuSIZE   zu

Format specifier for size_t variables in a OS-independent, processor architecture-independent way.

See https://stackoverflow.com/questions/40202990/print-a-size-t-in-a-os-independent-architecture-independent-way for the initial post

Definition at line 424 of file mrpt_macros.h.

◆ QUOTE

#define QUOTE (   name)    #name

Definition at line 426 of file mrpt_macros.h.

◆ STR

#define STR (   macro)    QUOTE(macro)

Definition at line 427 of file mrpt_macros.h.

◆ THROW_EXCEPTION

#define THROW_EXCEPTION (   msg)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\
auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\
auxCompStr << msg << std::endl; \
throw std::logic_error( auxCompStr.str() );\
}\
#define __CURRENT_FUNCTION_NAME__
A macro for obtaining the name of the current function:
Definition: mrpt_macros.h:146
Parameters
msgThis can be a char*, a std::string, or a literal string. Defines a unified way of reporting exceptions
See also
MRPT_TRY_START, MRPT_TRY_END, THROW_EXCEPTION_FMT

Definition at line 154 of file mrpt_macros.h.

◆ THROW_EXCEPTION_FMT

#define THROW_EXCEPTION_FMT (   _FORMAT_STRING,
  ... 
)     THROW_EXCEPTION(mrpt::format(_FORMAT_STRING,__VA_ARGS__))

Definition at line 163 of file mrpt_macros.h.

◆ THROW_STACKED_EXCEPTION

#define THROW_STACKED_EXCEPTION (   e)
Value:
{\
std::string _tse_str(e.what());\
_tse_str+= mrpt::format(" %s:%i: In `%s`\n", __FILE__,__LINE__, __CURRENT_FUNCTION_NAME__);\
throw std::logic_error( _tse_str );\
}
GLsizei const GLchar ** string
Definition: glext.h:3919
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
See also
MRPT_TRY_START, MRPT_TRY_END

Definition at line 185 of file mrpt_macros.h.

◆ THROW_STACKED_EXCEPTION_CUSTOM_MSG1

#define THROW_STACKED_EXCEPTION_CUSTOM_MSG1 (   e,
  msg 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << e.what() ; \
auxCompStr << msg << std::endl; \
throw std::logic_error( auxCompStr.str() );\
}\

Definition at line 196 of file mrpt_macros.h.

◆ THROW_STACKED_EXCEPTION_CUSTOM_MSG2

#define THROW_STACKED_EXCEPTION_CUSTOM_MSG2 (   e,
  stuff,
  param1 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << e.what() ; \
auxCompStr << mrpt::format( stuff, param1 ) << std::endl; \
throw std::logic_error( auxCompStr.str() );\
}\

Definition at line 208 of file mrpt_macros.h.

◆ THROW_TYPED_EXCEPTION

#define THROW_TYPED_EXCEPTION (   msg,
  exceptionClass 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\
auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\
auxCompStr << msg << std::endl; \
throw exceptionClass( auxCompStr.str() );\
}\

Defines a unified way of reporting exceptions of type different than "std::exception".

See also
MRPT_TRY_START, MRPT_TRY_END

Definition at line 170 of file mrpt_macros.h.

◆ THROW_TYPED_EXCEPTION_FMT

#define THROW_TYPED_EXCEPTION_FMT (   exceptionClass,
  _FORMAT_STRING,
  ... 
)     THROW_TYPED_EXCEPTION(mrpt::format(_FORMAT_STRING,__VA_ARGS__), exceptionClass)

Definition at line 179 of file mrpt_macros.h.

◆ USIZE_STR

#define USIZE_STR   STR(PRIuSIZE)

Definition at line 428 of file mrpt_macros.h.




Page generated by Doxygen 1.9.1 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at mar 26 may 2026 13:12:03 CEST