GTIRB  v2.1.0
GrammaTech Intermediate Representation for Binaries: C++ API
Export.hpp
Go to the documentation of this file.
1 //===- Export.hpp -----------------------------------------------*- C++ -*-===//
2 //
3 // Copyright (C) 2020 GrammaTech, Inc.
4 //
5 // This code is licensed under the MIT license. See the LICENSE file in the
6 // project root for license terms.
7 //
8 // This project is sponsored by the Office of Naval Research, One Liberty
9 // Center, 875 N. Randolph Street, Arlington, VA 22203 under contract #
10 // N68335-17-C-0700. The content of the information does not necessarily
11 // reflect the position or policy of the Government and no official
12 // endorsement should be inferred.
13 //
14 //===----------------------------------------------------------------------===//
15 #ifndef GTIRB_EXPORT_H
16 #define GTIRB_EXPORT_H
17 
19 #ifndef __has_declspec_attribute
20 #define __has_declspec_attribute(x) 0
21 #endif
22 
23 #ifndef __has_attribute
24 #define __has_attribute(x) 0
25 #endif
26 
32 #if defined(_MSC_VER) || __has_declspec_attribute(dllexport)
33 // Defined by the build system (CMake or SCons). This should only be defined by
34 // the build system which generates the GTIRB library. Users of the library
35 // should NOT define this.
36 #ifdef GTIRB_gtirb_EXPORTS
37 #define GTIRB_EXPORT_API _declspec(dllexport)
38 #else
39 // Note: We do not have clients explicitly dllimport from the gtirb
40 // library. GTIRB exports no data symbols. And using dllimport is
41 // optional for function symbols (dllimport provides only a very
42 // slight performance improvement on function calls). Using dllimport
43 // creates a certain amount of headache for Windows clients that may
44 // want to sometimes statically and sometimes dynamically link against
45 // GTIRB. The confusion and frustration this creates generally
46 // outweighs the performance benefit.
47 #define GTIRB_EXPORT_API
48 #endif // GTIRB_gtirb_EXPORTS
49 #elif defined(__GNUC__) || __has_attribute(visibility)
50 #define GTIRB_EXPORT_API __attribute__((visibility("default")))
51 #else
52 #define GTIRB_EXPORT_API
53 #endif
54 
55 #endif // GTIRB_EXPORT_H