macros.h

Go to the documentation of this file.
00001 /*
00002 *    Copyright (c) 2007. The BATI team. All right reserved.
00003 *
00004 *    This file is part of BATI library.
00005 *
00006 *    BATI library is free software: you can redistribute it and/or modify
00007 *    it under the terms of the GNU General Public License as published by
00008 *    the Free Software Foundation, either version 3 of the License, or
00009 *    (at your option) any later version.
00010 *
00011 *    BATI library  is distributed in the hope that it will be useful,
00012 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 *    GNU General Public License for more details.
00015 *
00016 *    You should have received a copy of the GNU General Public License
00017 *    along with BATI library.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 #include <stdlib.h>
00023 
00024 
00025 
00026 #define NO_ERROR 0
00027 
00028 
00029 
00030 
00031 /*---------------------------------------------------
00032   Macros 
00033   ----------------------------------------------------*/
00034 
00035 /* Macro pour afficher message */
00036 #define ERREUR(message) \
00037   {\
00038     printf("\nERREUR --> fichier %s ligne %d : \n%s\n \n", __FILE__, __LINE__, message) ;\
00039     exit(1);\
00040   }\
00041 
00042 
00043 
00044 /* Macro permettant de verifier si un pointeur pointe sur NULL 
00045 et affiche chaine passee en param si oui */
00046 #define VERIF_PT_NULL(PT, CHAINE)\
00047   if(PT == NULL)\
00048       {\
00049       printf("\nVerif_pt_null : le pointeur verifie a renvoye NULL \n");\
00050       ERREUR(CHAINE);\
00051     }\
00052 
00053 
00054 /* Macro pour allouer : verifie si null et affiche mess si pb */
00055 #define ALLOUER(PTR, NB, TYPE)  \
00056   {\
00057     PTR = (TYPE*)malloc ((NB) * sizeof(TYPE));  \
00058     VERIF_PT_NULL(PTR,"Allocation Impossible");\
00059     }\
00060 
00061 
00062 /* macro pour calculer le carré d'un nombre */
00063 #define MULTIPLIER(x,y) ((x)*(y))
00064 
00065 
00066 /* valeur absolue */
00067 #ifndef ABS
00068 #define ABS(x) ( (x) > 0 ? x : -(x) )
00069 #endif
00070 

Generated on Tue Apr 22 13:31:02 2008 for donnee1D by  doxygen 1.5.3