| … | … | @@ -1,63 +0,0 @@ |
| 1 | | /* |
| 2 | | * opencog/util/macros.h |
| 3 | | * |
| 4 | | * Copyright (C) 2002-2007 Novamente LLC |
| 5 | | * All Rights Reserved |
| 6 | | * |
| 7 | | * Written by Nicu Tofan <xtnickx@users.sourceforge.net> |
| 8 | | * |
| 9 | | * This program is free software; you can redistribute it and/or modify |
| 10 | | * it under the terms of the GNU Affero General Public License v3 as |
| 11 | | * published by the Free Software Foundation and including the exceptions |
| 12 | | * at http://opencog.org/wiki/Licenses |
| 13 | | * |
| 14 | | * This program is distributed in the hope that it will be useful, |
| 15 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | | * GNU General Public License for more details. |
| 18 | | * |
| 19 | | * You should have received a copy of the GNU Affero General Public License |
| 20 | | * along with this program; if not, write to: |
| 21 | | * Free Software Foundation, Inc., |
| 22 | | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 23 | | */ |
| 24 | | |
| 25 | | #ifndef _OPENCOG_MACROS_H |
| 26 | | #define _OPENCOG_MACROS_H |
| 27 | | |
| 28 | | /** \addtogroup grp_cogutil |
| 29 | | * @{ |
| 30 | | */ |
| 31 | | |
| 32 | | //! helper to create strings at compile time |
| 33 | | #define STRINGIFY(x) #x |
| 34 | | //! convert the symbol to a string |
| 35 | | #define TOSTRING(x) STRINGIFY(x) |
| 36 | | //! indicate current file and line using (file:line) format |
| 37 | | #define TRACE_INFO " (" __FILE__ ":" TOSTRING(__LINE__) ")" |
| 38 | | //! suppress compiler warnings about unused variables |
| 39 | | #define OC_UNUSED(varname) (void)varname; |
| 40 | | //! check the return value of a fread; sets b_read local variable |
| 41 | | //! to false for failure; b_read must have been declared before: |
| 42 | | //! bool b_read = true; |
| 43 | | #define FREAD_CK(ptr,size,count,stream) \ |
| 44 | | b_read = b_read && (fread(ptr,size,count,stream)==(size_t)count) |
| 45 | | //! check the b_read used for fread function and throw an exception |
| 46 | | //! if b_read is false |
| 47 | | #define CHECK_FREAD \ |
| 48 | | { if ( !b_read ) throw IOException(TRACE_INFO, "%s - failed to read.", __FUNCTION__ ); } |
| 49 | | |
| 50 | | |
| 51 | | /** @}*/ |
| 52 | | |
| 53 | | /// macro available from gcc 4.7 |
| 54 | | #ifndef _GLIBCXX_USE_NOEXCEPT |
| 55 | | # if __GNUC__ >= 4 |
| 56 | | # define _GLIBCXX_USE_NOEXCEPT throw() |
| 57 | | /// For non-gnu systems... |
| 58 | | # else |
| 59 | | # define _GLIBCXX_USE_NOEXCEPT |
| 60 | | # endif |
| 61 | | #endif |
| 62 | | |
| 63 | | #endif // _OPENCOG_MACROS_H |