Main MRPT website > C++ reference for MRPT 1.5.7
initializer.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 /** \file Usage: MRPT_INITIALIZER(func) { ... }
13  * MRPT_INITIALIZER() should be used only once per library in its present cross-platform implementation.
14  */
15 #if defined(_MSC_VER)
16  #include <mrpt/config.h>
17  #if defined(MRPT_BUILT_AS_DLL)
18  #include <windows.h>
19  #define MRPT_INITIALIZER(f) \
20  static void f(); \
21  BOOL WINAPI DllMain(HINSTANCE /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpvReserved*/) \
22  { \
23  switch (fdwReason) { \
24  case DLL_PROCESS_ATTACH: \
25  f(); \
26  } \
27  return TRUE; \
28  } \
29  static void f(void)
30 #else
31  // Static libs in Windows: the hardest case, subject to
32  #define MRPT_INITIALIZER(f) \
33  static void f(void); \
34  struct f##_t_ { f##_t_(void) { f(); } }; static f##_t_ f##_; \
35  static void f(void)
36 #endif
37 #else
38  #include <stdio.h>
39  #include <stdlib.h>
40  #define MRPT_INITIALIZER(f) \
41  static void f(void) __attribute__((constructor)); \
42  static void f(void)
43 #endif



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019