source: cpp/common/nonstd.h @ 138

Last change on this file since 138 was 135, checked in by sz, 11 years ago

neuron layout algorithm (for schematic drawing), usage example in frams/_demos/neuro_layout_test.cpp

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#ifndef _NONSTD_H_
6#define _NONSTD_H_
7
8#define SAFEDELETE(p) {if (p) {delete p; p=NULL;}}
9#define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}}
10
11#define roundToInt(x) ((int)(floor((x)+0.5)))
12
13
14#define CPP_STR(s) CPP_XSTR(s)
15#define CPP_XSTR(s) #s
16
17
18#define DB(x) //output debug info. If needed, use #define DB(x) x
19//#define DB(x) x
20
21
22// ms visual c++
23#ifdef _MSC_VER
24 #include <stdio.h> //this #include must be present before two #defines below can be used, otherwise one will see: '_vsnprintf': attributes inconsistent with previous declaration, stdio.h:358
25 #define vsnprintf _vsnprintf
26 #define snprintf _snprintf
27#endif
28
29#ifdef MOBILE2D
30 #define strdup _strdup
31#endif
32
33/////////////////////////////////////////////////////// 64-bit int type and other macros
34#ifdef _WIN32
35        typedef __int64 LONGLONG;
36        #define PATH_SEPARATOR_CHAR '\\'
37        #define PATH_SEPARATOR_STRING "\\"
38        #define FPU_THROWS_EXCEPTIONS
39#else
40        #define LONGLONG long long int
41        #define PATH_SEPARATOR_CHAR '/'
42        #define PATH_SEPARATOR_STRING "/"
43#endif
44
45#define FOPEN_READ_BINARY "rb"
46// no FOPEN_READ_TEXT
47#define FOPEN_WRITE_BINARY "wb"
48#define FOPEN_APPEND_BINARY "ab"
49#define FOPEN_WRITE_TEXT "wt"
50#define FOPEN_APPEND_TEXT "at"
51
52#ifdef LINUX
53 #include <strings.h>
54 #ifndef __CYGWIN__
55  #define stricmp(a,b) strcasecmp(a,b)
56 #endif
57#endif
58
59#ifdef MACOS
60 #define stricmp(a,b) strcasecmp(a,b)
61#endif
62
63#ifdef IPHONE
64 #include <string>
65 std::string getAppHome();
66 std::string getAppResources();
67 #define GET_APP_HOME getAppHome()
68 #define GET_APP_RESOURCES getAppResources()
69#endif
70
71#ifdef SHP
72 #define GET_APP_HOME "/Home/"
73 #define GET_APP_RESOURCES "/Res/"
74#endif
75
76#ifdef TIZEN
77 #define GET_APP_HOME "/data/"
78 #define GET_APP_RESOURCES "/res/"
79#endif
80
81#ifdef __ANDROID__
82 #define GET_APP_HOME getAppHome()
83 #define GET_APP_RESOURCES "./" //w APK trzymamy w katalogu w "assets", bo w "res" nie ma podkatalogow ani odwolywania sie po nazwach
84#endif
85
86#ifdef LINUX
87 #define GET_APP_HOME "./"
88 #define GET_APP_RESOURCES "./"
89#endif
90
91#if defined(_WIN32) && !defined(SHP)
92    #define GET_APP_HOME ".\\"
93    #define GET_APP_RESOURCES ".\\"
94#endif
95
96#ifdef INITIAL_DIR_IS_HOME
97 #include "cwd.h"
98 #ifdef GET_APP_HOME
99  #undef GET_APP_HOME
100 #endif
101 #define GET_APP_HOME getAppHome()
102#endif
103
104#ifdef INITIAL_DIR_IS_RES
105 #include "cwd.h"
106 #ifdef GET_APP_RESOURCES
107  #undef GET_APP_RESOURCES
108 #endif
109 #define GET_APP_RESOURCES getAppResources()
110#endif
111
112//typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char
113//typedef char byte; //rozne srodowiska c++ definiuja byte jako unsigned char! w javie jest inaczej -> trzeba i tak zmienic w portowanych zrodlach byte na char.
114
115
116#endif
117
Note: See TracBrowser for help on using the repository browser.