-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyassert.c
40 lines (36 loc) · 1.26 KB
/
myassert.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifdef HAVE_CONFIG
#include "config.h"
#endif
/*****************************************************************************
* auteur : Gilles Subrenat ( que je remercie )
*
* fichier : myassert.c
*
* note :
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "myassert.h"
void myassert_func(bool condition, const char *message, const char *fileName,
const char *functionName, int line)
{
if (! condition)
{
fprintf(stderr, "/---------------------------\n");
fprintf(stderr, "| Erreur détectée !\n");
fprintf(stderr, "| fichier : %s\n", fileName);
fprintf(stderr, "| ligne : %d\n", line);
fprintf(stderr, "| fonction : %s\n", functionName);
fprintf(stderr, "| pid : %d\n", getpid());
fprintf(stderr, "| Message :\n");
fprintf(stderr, "| -> %s\n", message);
fprintf(stderr, "| Message systeme:\n");
fprintf(stderr, "| -> ");
perror("");
fprintf(stderr, "| On stoppe le programme\n");
fprintf(stderr, "\\---------------------------\n");
exit(EXIT_FAILURE);
}
}