source: cpp/gdk/nonstd.h @ 68

Last change on this file since 68 was 68, checked in by Maciej Komosinski, 13 years ago

added missing sources; updated sources for compatibility with vs2008 and added project files

  • 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#endif
52
53#ifdef __BORLANDC__
54        #define fileExists(f) (!access(f,0))
55        #include "stdlib.h" //random
56        #define rnd01 ((double)((double)_lrand()/(double)(LRAND_MAX+1)))
57        //#define rnd01 ((double)((double)rand()/(RAND_MAX+1)))
58        #define rnd0N(num) ((double)((num)*rnd01))
59        #define randomN(num) random(num) //uses _lrand
60#else
61        #ifdef _MSC_VER
62        #define fileExists(f) (!access(f,0))
63        #else
64        #define fileExists(f) (!access(f,R_OK))
65        #endif
66
67        //#define FLOATRAND
68        #ifdef FLOATRAND
69                #define randomN(x) ((int)((x)*drand48()))
70                #define rnd01 (drand48())
71                #define rnd0N(x) (drand48()*(x))
72        #else
73                #define rnd01 ((double)(rand()/(RAND_MAX+1.0)))
74                #define rnd0N(x) ((x)*rnd01)
75                #define randomN(x) ((int)rnd0N(x))
76        #endif
77#endif
78
79
80#ifdef __GNUC__
81/*
82        #define min(a,b) (((a)>(b))?(b):(a))
83        #define max(a,b) (((a)>(b))?(a):(b))
84        #define abs(a) ((a)>=0?(a):-(a))
85*/
86#include <algorithm>
87using namespace std;
88#endif
89
90#ifdef DEFINE_STRICMP_AS_STRCASECMP
91#define stricmp(a,b) strcasecmp(a,b)
92#endif
93
94#endif
Note: See TracBrowser for help on using the repository browser.