1 /*=========================================================================
4 Module: $RCSfile: creaSystem.h,v $
6 Date: $Date: 2011/02/22 11:12:40 $
7 Version: $Revision: 1.13 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/creatools/license.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
21 *\brief contains all the OS depending stuff
23 #ifndef __creaSystem_h__
24 #define __creaSystem_h__
26 #include "creaConfigure.h"
28 #define BOOST_FILESYSTEM_VERSION 2
30 // We try for Visual 6..????
31 //#pragma warning( disable : 4786)
33 //-----------------------------------------------------------------------------
34 //This is needed when compiling in debug mode
36 // 'identifier' : class 'type' needs to have dll-interface to be used by
37 // clients of class 'type2'
38 #pragma warning ( disable : 4251 )
39 // non dll-interface class 'type' used as base for dll-interface class 'type2'
40 #pragma warning ( disable : 4275 )
41 // 'identifier' : identifier was truncated to 'number' characters in the
43 #pragma warning ( disable : 4786 )
44 //'identifier' : decorated name length exceeded, name was truncated
45 #pragma warning ( disable : 4503 )
46 // C++ exception specification ignored except to indicate a
47 // function is not __declspec(nothrow)
48 #pragma warning ( disable : 4290 )
49 // signed/unsigned mismatch
50 #pragma warning ( disable : 4018 )
51 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
52 // produce errors if applied using infix notation
53 #pragma warning ( disable : 4284 )
54 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
55 // //#pragma warning ( disable : 4800 )
59 #include <stdio.h> // for printf, ...
60 #include <iostream> // for cout, endl, ...
63 // Micro$oft related stuff
68 //#include <curses.h> // for getch
71 //-----------------------------------------------------------------------------
72 // Micro$oft shared library related stuff
74 // all the classes that must be visible outside the crea library
75 // should be defined as :
76 // class CREA_EXPORT ClassName
84 //&& defined(BUILD_SHARED_LIBS)
86 #define CREA_EXPORT2 export
92 #endif // defined(_WIN32) && defined(BUILD_SHARED_LIBS)
97 #if defined(_WIN32) && defined(CREA_BUILD_SHARED)
98 #ifdef CREA_EXPORT_SYMBOLS
99 #define CREA_EXPORT __declspec( dllexport )
101 #define CREA_EXPORT __declspec( dllimport )
103 #define CREA_CDECL __cdecl
107 #endif // defined(_WIN32) && defined(CREA_BUILD_SHARED)
112 #endif //__BORLANDC__
116 // ----------------------------------------------------------------------------
118 // ----------------------------------------------------------------------------
119 //#include "creaWx.h"
122 #ifdef _USE_WXWIDGETS_
123 #include "wx/wxprec.h"
124 #include <wx/datetime.h>
135 #endif //_USE_WXWIDGETS_
137 //-----------------------------------------------------------------------------
139 //-----------------------------------------------------------------------------
145 #define CREA_STRINGIFY(A) #A
146 #define CREA_STRINGIFY_SYMBOL(A) CREA_STRINGIFY(A)
150 CREA_EXPORT inline const std::string& CREA_CDECL GetVersion()
152 static const std::string v(CREA_STRINGIFY_SYMBOL(CREA_VERSION));
158 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
163 typedef signed char int8_t;
164 typedef signed short int16_t;
165 typedef signed int int32_t;
166 typedef unsigned char uint8_t;
167 typedef unsigned short uint16_t;
168 typedef unsigned int uint32_t;
171 #include <inttypes.h>
175 #ifdef CMAKE_HAVE_STDINT_H
178 #ifdef CMAKE_HAVE_INTTYPES_H
179 // Old system only have this
180 #include <inttypes.h> // For uint8_t uint16_t and uint32_t
183 // Broken plateforms do not respect C99 and do not provide those typedef
184 // Special case for recent Borland compiler, comes with stdint.h
185 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) \
186 || defined(__MINGW32__)
187 typedef signed char int8_t;
188 typedef signed short int16_t;
189 typedef signed int int32_t;
190 typedef unsigned char uint8_t;
191 typedef unsigned short uint16_t;
192 typedef unsigned int uint32_t;
194 /// \todo Find a clever way to deal with int64_t, uint64_t
197 #error "Sorry your plateform is not supported"
198 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) || defined(__MINGW32__)
199 #endif // CMAKE_HAVE_INTTYPES_H
200 #endif // CMAKE_HAVE_STDINT_H
202 // Basically for VS6 and bcc 5.5.1:
204 #define UINT32_MAX (4294967295U)
207 //-----------------------------------------------------------------------------
210 //-----------------------------------------------------------------------------
214 /// System related stuff
217 /// returns true iff the program has a tty
219 CREA_EXPORT static int GetAppPath(char *pname, size_t pathsize);
220 CREA_EXPORT static std::string GetDllAppPath(std::string &nomdll);
221 CREA_EXPORT static std::string GetDllAppPath(const char *nomdll);
222 CREA_EXPORT static std::string GetExecutablePath();
223 CREA_EXPORT static void createDirectory(const char* directorypath);
227 //-----------------------------------------------------------------------------
231 #define VALID_FILE_SEPARATOR "\\"
232 #define INVALID_FILE_SEPARATOR "/"
234 #define INVALID_FILE_SEPARATOR "\\"
235 #define VALID_FILE_SEPARATOR "/"