gnss_error.h

Go to the documentation of this file.
00001 /**
00002 \file    gnss_error.h
00003 \brief   GNSS core 'c' function library: error and warning macros.
00004 \author  Glenn D. MacGougan (GDM)
00005 \date    2008-03-19
00006 \since   2008-03-19
00007 
00008 \remarks
00009 
00010 \b "LICENSE INFORMATION" \n
00011 Copyright (c) 2008, refer to 'author' doxygen tags \n
00012 All rights reserved. \n
00013 
00014 Redistribution and use in source and binary forms, with or without
00015 modification, are permitted provided the following conditions are met: \n
00016 
00017 - Redistributions of source code must retain the above copyright
00018   notice, this list of conditions and the following disclaimer. \n
00019 - Redistributions in binary form must reproduce the above copyright
00020   notice, this list of conditions and the following disclaimer in the
00021   documentation and/or other materials provided with the distribution. \n
00022 - The name(s) of the contributor(s) may not be used to endorse or promote 
00023   products derived from this software without specific prior written 
00024   permission. \n
00025 
00026 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 
00027 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00028 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00029 DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00030 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00031 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00032 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00033 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00034 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00035 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00036 SUCH DAMAGE.
00037 */
00038 
00039 #ifndef _C_ERROR_H_
00040 #define _C_ERROR_H_
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 #include <stdio.h>
00047 
00048 /**
00049 \brief    Output an error message with the following format:\n 
00050           file, function, line number, msg\n
00051 
00052 \code
00053 char msg[128];
00054 char fname[24];
00055 sprintf( fname, "test.txt" );
00056 sprintf( msg, "Unable to open %s", fname );
00057 ERROR_MSG( msg );
00058 \endcode
00059 
00060 \author   Glenn D. MacGougan (GDM)
00061 \date     2008-03-19
00062 \since    2008-03-19
00063 
00064 */
00065 #define GNSS_ERROR_MSG( msg )  \
00066 { \
00067   const char *themsg = msg; \
00068   if( themsg != NULL ) \
00069   { \
00070     printf( "\n%s,\n%s, %d,\n%s\n", __FILE__, __FUNCTION__, __LINE__, themsg ); \
00071   } \
00072   else \
00073   { \
00074   printf( "\n%s,\n%s, %d,\nUnknown Error\n", __FILE__, __FUNCTION__, __LINE__ ); \
00075   } \
00076 }
00077 
00078 #ifdef __cplusplus
00079 }
00080 #endif
00081 
00082 
00083 #endif // _C_ERROR_H_
SourceForge.net Logo