HermesCommon  3.0
compat.h
Go to the documentation of this file.
1 // This file is part of HermesCommon
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://www.hpfem.org/.
5 //
6 // Hermes2D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes2D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes2D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef __HERMES_COMMON_COMPAT_H
24 #define __HERMES_COMMON_COMPAT_H
25 #include <stdio.h>
26 #include "stddef.h"
27 #include "config.h"
28 #include <cstddef>
29 
30 #ifndef HAVE_FMEMOPEN
31 FILE *fmemopen(void *buf, size_t size, const char *opentype);
33 #endif
34 
35 // Windows DLL export/import definitions.
36 #if defined (HERMES_STATIC_LIBS)
37 #define HERMES_API
38 #else
39 #if defined (AGROS)
40 #if defined (HERMES_FOR_AGROS)
41 #define HERMES_API __declspec(dllexport)
42 #else
43 #define HERMES_API __declspec(dllimport)
44 #endif
45 #else
46 #if defined(WIN32) || defined(_WINDOWS)
47 // Visual Studio 2010.
48 #if defined(EXPORT_HERMES_DLL)
49 // when building DLL (target project defines this macro)
50 #define HERMES_API __declspec(dllexport)
51 #else
52 // when using the DLL by a client project
53 #define HERMES_API __declspec(dllimport)
54 #endif
55 #else
56 #define HERMES_API
57 #endif
58 #endif
59 #endif
60 
61 #if defined(WIN32) || defined(_WINDOWS)
62 #ifdef HERMES_COMMON
63 #define HERMES_COMMON_API __declspec(dllexport)
64 #else
65 #define HERMES_COMMON_API __declspec(dllimport)
66 #endif
67 #else
68 #define HERMES_COMMON_API
69 #endif
70 
71 #ifndef HAVE_STRCASECMP
72 #define strcasecmp strcmp
73 #endif
74 
75 #ifdef __GNUC__
76 #define NORETURN __attribute__((noreturn))
77 #else
78 #define NORETURN
79 #ifndef __attribute__
80 #define __attribute__(x)
81 #endif
82 #endif
83 
84 // If C++ 11 is not supported
85 namespace std
86 {
87 #if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ >= 5))
88 # define HACK_GCC_ITS_CPP0X 1
89 #endif
90 #if defined(nullptr_t) || (__cplusplus >= 199711L) || defined(HACK_GCC_ITS_CPP0X)
91 #else
92 #define nullptr NULL
93 #endif
94 }
95 
96 #endif
Definition: compat.h:85
FILE * fmemopen(void *buf, size_t size, const char *opentype)
Implementation of GNU fmemopen. Intended to be used if the current platform does not support it...