Newer
Older
project / modules / libsc / include / sc_os.h
Nomura Kei on 26 Sep 2022 2 KB UPDATE
/**
 * @file      sc_os.h
 * @bried     OS判定マクロを定義したヘッダーファイル
 * @author    Nomura Kei
 * @copyright 2003 - 2022  Nomura Kei
 *
 * 次の OS を判定するマクロが定義されます。
 * - IS_WINDOWS
 * - IS_LINUX
 * - IS_UNIX
 * - IS_BSD
 * - IS_MAC
 * - IS_VXWORKS
 */
#ifndef SC_OS_H
#define SC_OS_H


////////////////////////////////////////////////////////////////////////////////
//
// Windows 判定
// Windows の場合、windows.h と winsock2.h が include されます。
//
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) \
 || defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(__WIN64__)
#define IS_WINDOWS (1)
// dMC にて winsock2.h を使用する場合、_WINSOCKAPI_ の定義が必要
// 詳細は、下記 URL 参照
// http://www.digitalmars.com/d/archives/c++/idde/326.html
#ifdef __DMC__
#define _WINSOCKAPI_
#include <sys/types.h>
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#include <winsock2.h>
#include <windows.h>
#else
#define IS_WINDOWS (0)
#endif


////////////////////////////////////////////////////////////////////////////////
//
// Linux 判定
//
#if defined(linux) || defined(__linux) || defined(__linux__)
#define IS_LINUX (1)
#else
#define IS_LINUX (0)
#endif


////////////////////////////////////////////////////////////////////////////////
//
// UNIX互換判定
//
#if defined(unix) || defined(__unix) || defined(__unix__)
#define IS_UNIX (1)
#else
#define IS_UNIX (0)
#endif


////////////////////////////////////////////////////////////////////////////////
//
// BSD系判定
//
#if defined(BSD) || defined(_BSD) || defined(__BSD)
#define IS_BSD (1)
#else
#define IS_BSD (0)
#endif


////////////////////////////////////////////////////////////////////////////////
//
// MAC判定
//
#if defined(mac) || defined(MAC) || defined(_MAC)
#define IS_MAC (1)
#else
#define IS_MAC (0)
#endif


////////////////////////////////////////////////////////////////////////////////
//
// VxWorks 判定
//
#if defined(VXWORKS) || defined(VxWorks)
#define IS_VXWORKS (1)
#else
#define IS_VXWORKS (0)
#endif


#endif	// SC_OS_H