source: cpp/gdk/nonstd.h @ 73

Last change on this file since 73 was 69, checked in by sz, 14 years ago

removed unnecessary files. all GDK samples can be built again (including neurotest). TODO: add #define GDK_WITHOUT_FRAMS to all VS projects! Note: read Makefile before syncing frams<->GDK!

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1//Define rnd01, rnd0N, and randomN so that they
2//work in your C++ environment.
3//Some other functions/macros may also be needed if they
4//are missing in your environment, like min, max, etc.
5
6#ifndef __NONSTD_H
7#define __NONSTD_H
8
9#define APPLICATION_NAME "Framsticks"
10#define MAIN_FRAMSTICKS
11#define SAFEDELETE(p) {if (p) {delete p; p=NULL;}}
12#define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}}
13
14//#ifndef _Windows   included below?
15//#include <stdlib.h>
16//#endif
17
18#define DB(x) //output debug info. If needed, use #define DB(x) x
19//#define DB(x) x
20
21// ms visual c++
22#ifdef _MSC_VER
23 #define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
24 #include <windows.h>
25 #include <stdio.h>
26 #include <stdarg.h>
27 #define vsnprintf _vsnprintf
28 #define _USE_MATH_DEFINES //after this is defined, the next #include <math.h> or <cmath> will define:
29 //#ifndef M_PI
30 //#define M_PI 3.1415926535897932384626433832795
31 //#endif
32 //#ifndef M_PI_2
33 //#define M_PI_2 (M_PI/2)
34 //#endif
35
36#endif
37
38/////////////////////////////////////////////////////// 64-bit int type and other macros
39#ifdef _Windows
40        typedef __int64 LONGLONG;
41        #define PATHSEPARATORCHAR '\\'
42        #define PATHSEPARATORSTRING "\\"
43        #define FPU_THROWS_EXCEPTIONS
44        #define FOPEN_READ "rt"
45        #define FOPEN_WRITE "wt"
46        #define FOPEN_APPEND "at"
47#else
48        #define LONGLONG long long int
49        #define PATHSEPARATORCHAR '/'
50        #define PATHSEPARATORSTRING "/"
51        #define FOPEN_READ "r"
52        #define FOPEN_WRITE "w"
53        #define FOPEN_APPEND "a"
54#endif
55
56#ifdef __BORLANDC__
57        #define fileExists(f) (!access(f,0))
58        #include "stdlib.h" //random
59        #define rnd01 ((double)((double)_lrand()/(double)(LRAND_MAX+1)))
60        //#define rnd01 ((double)((double)rand()/(RAND_MAX+1)))
61        #define rnd0N(num) ((double)((num)*rnd01))
62        #define randomN(num) random(num) //uses _lrand
63#else
64        #ifdef _MSC_VER
65        #define fileExists(f) (!access(f,0))
66        #else
67        #define fileExists(f) (!access(f,R_OK))
68        #endif
69
70        //#define FLOATRAND
71        #ifdef FLOATRAND
72                #define randomN(x) ((int)((x)*drand48()))
73                #define rnd01 (drand48())
74                #define rnd0N(x) (drand48()*(x))
75        #else
76                #define rnd01 ((double)(rand()/(RAND_MAX+1.0)))
77                #define rnd0N(x) ((x)*rnd01)
78                #define randomN(x) ((int)rnd0N(x))
79        #endif
80#endif
81
82
83#ifdef __GNUC__
84/*
85        #define min(a,b) (((a)>(b))?(b):(a))
86        #define max(a,b) (((a)>(b))?(a):(b))
87        #define abs(a) ((a)>=0?(a):-(a))
88*/
89#include <algorithm>
90using namespace std;
91#endif
92
93#ifdef DEFINE_STRICMP_AS_STRCASECMP
94#define stricmp(a,b) strcasecmp(a,b)
95#endif
96
97#endif
Note: See TracBrowser for help on using the repository browser.