MNN  1.0
MNNDefine.h
浏览该文件的文档.
1 //
2 // MNNDefine.h
3 // MNN
4 //
5 // Created by MNN on 2018/08/09.
6 // Copyright © 2018, Alibaba Group Holding Limited
7 //
8 
9 #ifndef MNNDefine_h
10 #define MNNDefine_h
11 
12 #include <assert.h>
13 #include <stdio.h>
14 
15 #if defined(__APPLE__)
16 #include "TargetConditionals.h"
17 #if TARGET_OS_IPHONE
18 #define MNN_BUILD_FOR_IOS
19 #endif
20 #endif
21 
22 #ifdef MNN_USE_LOGCAT
23 #include <android/log.h>
24 #define MNN_ERROR(format, ...) __android_log_print(ANDROID_LOG_ERROR, "MNNJNI", format, ##__VA_ARGS__)
25 #define MNN_PRINT(format, ...) __android_log_print(ANDROID_LOG_INFO, "MNNJNI", format, ##__VA_ARGS__)
26 #else
27 #define MNN_PRINT(format, ...) printf(format, ##__VA_ARGS__)
28 #define MNN_ERROR(format, ...) printf(format, ##__VA_ARGS__)
29 #endif
30 
31 #ifdef DEBUG
32 #define MNN_ASSERT(x) \
33  { \
34  int res = (x); \
35  if (!res) { \
36  MNN_ERROR("Error for %s, %d\n", __FILE__, __LINE__); \
37  assert(res); \
38  } \
39  }
40 #else
41 #define MNN_ASSERT(x) \
42  { \
43  int res = (x); \
44  if (!res) { \
45  MNN_ERROR("Error for %s, %d\n", __FILE__, __LINE__); \
46  } \
47  }
48 #endif
49 
50 #define FUNC_PRINT(x) MNN_PRINT(#x "=%d in %s, %d \n", x, __func__, __LINE__);
51 #define FUNC_PRINT_ALL(x, type) MNN_PRINT(#x "=" #type " %" #type " in %s, %d \n", x, __func__, __LINE__);
52 
53 #define MNN_PUBLIC __attribute__((visibility("default")))
54 
55 #endif /* MNNDefine_h */