Newer
Older
snipet / libscpp / trunk / include / scpp_os.hpp
  1. /* =============================================================================
  2. * scpp_os.hpp
  3. * Copyright (c) 2003 - 2011 Nomura Kei
  4. * LICENSE :
  5. * LGPL (GNU Lesser General General Public License - Version 3,29 June 2007)
  6. * http://www.gnu.org/copyleft/lesser.html
  7. * =============================================================================
  8. *
  9. * OS の判定を行う下記マクロ定数を定義している.
  10. *
  11. * SCPP_IS_WINDOWS 1/0 (Windows/Windows ではない)
  12. * SCPP_IS_LINUX 1/0 (Linux /Linux ではない)
  13. * SCPP_IS_UNIX 1/0 (UNIX系 /UNIX系 ではない)
  14. * SCPP_IS_BSD 1/0 (BSD系 /BSD系 ではない)
  15. * SCPP_IS_MAC 1/0 (Mac /Mac ではない)
  16. * SCPP_IS_VXWORKS 1/0 (VxWorks/VxWorks ではない)
  17. *
  18. * また, 各OSにおいて必須のヘッダファイルを include します.
  19. */
  20. #ifndef SCPP_OS_HPP
  21. #define SCPP_OS_HPP
  22.  
  23.  
  24. ////////////////////////////////////////////////////////////////////////////////
  25. //
  26. // Windows 判定
  27. //
  28. // Windows の場合, windows.h と winsock2.h を include しておく
  29. //
  30. #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) \
  31. || defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(__WIN64__)
  32. #define SCPP_IS_WINDOWS (1)
  33. // DMC にて winsock2.h を使用する場合, _WINSOCKAPI_ が必要
  34. // 詳細は下記 URL 参照
  35. // http://www.digitalmars.com/d/archives/c++/idde/326.html
  36. #ifdef __DMC__
  37. #define _WINSOCKAPI_
  38. #include <sys/types.h>
  39. #endif
  40. #ifndef _WIN32_WINNT
  41. #define _WIN32_WINNT 0x0501
  42. #endif
  43. #include <windows.h>
  44. #include <winsock2.h>
  45.  
  46. #else
  47. #define SCPP_IS_WINDOWS (0)
  48.  
  49. #endif
  50.  
  51.  
  52. ////////////////////////////////////////////////////////////////////////////////
  53. //
  54. // Linux 判定
  55. //
  56. #if defined(linux) || defined(__linux) || defined(__linux__)
  57. #define SCPP_IS_LINUX (1)
  58.  
  59. #else
  60. #define SCPP_IS_LINUX (0)
  61.  
  62. #endif
  63.  
  64.  
  65. ////////////////////////////////////////////////////////////////////////////////
  66. //
  67. // UNIX 判定
  68. //
  69. #if defined (unix) || defined(__unix) || defined(__unix__)
  70. #define SCPP_IS_UNIX (1)
  71.  
  72. #else
  73. #define SCPP_IS_UNIX (0)
  74.  
  75. #endif
  76.  
  77.  
  78. ////////////////////////////////////////////////////////////////////////////////
  79. //
  80. // BSD 判定
  81. //
  82. #if defined(BSD) || defined(_BSD) || defined(__BSD)
  83. #define SCPP_IS_BSD (1)
  84.  
  85. #else
  86. #define SCPP_IS_BSD (0)
  87.  
  88. #endif
  89.  
  90.  
  91. ////////////////////////////////////////////////////////////////////////////////
  92. //
  93. // Mac 判定
  94. //
  95. #if defined(mac) || defined(MAC) || defined(_MAC)
  96. #define SCPP_IS_MAC (1)
  97.  
  98. #else
  99. #define SCPP_IS_MAC (0)
  100.  
  101. #endif
  102.  
  103.  
  104. ////////////////////////////////////////////////////////////////////////////////
  105. //
  106. // VxWorks 判定
  107. //
  108. #if defined(VXWORKS) || defined(VxWorkd)
  109. #define SCPP_IS_VXWORKS (1)
  110.  
  111. #else
  112. #define SCPP_IS_VXWORKS (0)
  113.  
  114. #endif
  115.  
  116.  
  117. #endif // SCPP_OS_HPP
  118.