-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdebug.hpp
More file actions
33 lines (26 loc) · 1.13 KB
/
debug.hpp
File metadata and controls
33 lines (26 loc) · 1.13 KB
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
/* -*- coding: utf-8;mode:c++;c-file-style:"stroustrup" -*- */
/*
Licensed under the terms of the BSD 3-Clause
(see plotpy/__init__.py for details)
*/
#ifndef __DEBUG_HPP__
#define __DEBUG_HPP__
#define DEBUG 0
#if DEBUG
#define check(msg, x, n, r) \
if (x < 0 || x >= n) \
{ \
printf(msg "%d out of bound (%d)\n", x, n); \
return r; \
}
#define check_img_ptr(msg, p, r, img) \
if (p < img.base || p > (img.base + (img.ni - 1) * img.si + (img.nj - 1) * img.sj)) \
{ \
printf(msg "%p out of bound (%p,%dx%d, %dx%d\n", p, img.base, img.ni, img.si, img.nj, img.sj); \
return r; \
}
#else
#define check(msg, x, n, r) ;
#define check_img_ptr(msg, p, r, img) ;
#endif
#endif