00001 /* 00002 * Copyright (c) 2014, RoboPeak 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00016 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00017 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00018 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00019 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00021 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00022 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00023 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00025 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 */ 00028 /* 00029 * RoboPeak LIDAR System 00030 * Utility Functions 00031 * 00032 * Copyright 2009 - 2014 RoboPeak Team 00033 * http://www.robopeak.com 00034 * 00035 */ 00036 00037 #pragma once 00038 00039 00040 //------ 00041 /* _countof helper */ 00042 #if !defined(_countof) 00043 #if !defined(__cplusplus) 00044 #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0])) 00045 #else 00046 extern "C++" 00047 { 00048 template <typename _CountofType, size_t _SizeOfArray> 00049 char (*__countof_helper( _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray]; 00050 #define _countof(_Array) sizeof(*__countof_helper(_Array)) 00051 } 00052 #endif 00053 #endif 00054 00055 /* _offsetof helper */ 00056 #if !defined(offsetof) 00057 #define offsetof(_structure, _field) ((_word_size_t)&(((_structure *)0x0)->_field)) 00058 #endif 00059 00060 00061 #define BEGIN_STATIC_CODE( _blockname_ ) \ 00062 static class _static_code_##_blockname_ { \ 00063 public: \ 00064 _static_code_##_blockname_ () 00065 00066 00067 #define END_STATIC_CODE( _blockname_ ) \ 00068 } _instance_##_blockname_; 00069