xref: /freebsd/contrib/ncurses/include/ncurses_dll.h.in (revision 4e99f45480598189d49d45a825533a6c9e12f02c)
1/****************************************************************************
2 * Copyright 2018,2020 Thomas E. Dickey                                     *
3 * Copyright 2009,2014 Free Software Foundation, Inc.                       *
4 *                                                                          *
5 * Permission is hereby granted, free of charge, to any person obtaining a  *
6 * copy of this software and associated documentation files (the            *
7 * "Software"), to deal in the Software without restriction, including      *
8 * without limitation the rights to use, copy, modify, merge, publish,      *
9 * distribute, distribute with modifications, sublicense, and/or sell       *
10 * copies of the Software, and to permit persons to whom the Software is    *
11 * furnished to do so, subject to the following conditions:                 *
12 *                                                                          *
13 * The above copyright notice and this permission notice shall be included  *
14 * in all copies or substantial portions of the Software.                   *
15 *                                                                          *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 *                                                                          *
24 * Except as contained in this notice, the name(s) of the above copyright   *
25 * holders shall not be used in advertising or otherwise to promote the     *
26 * sale, use or other dealings in this Software without prior written       *
27 * authorization.                                                           *
28 ****************************************************************************/
29/* $Id: ncurses_dll.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */
30
31#ifndef NCURSES_DLL_H_incl
32#define NCURSES_DLL_H_incl 1
33
34/*
35 * MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64.
36 */
37#if defined(__MINGW64__)
38
39#ifndef _WIN64
40#define _WIN64 1
41#endif
42
43#elif defined(__MINGW32__)
44
45#ifndef _WIN32
46#define _WIN32 1
47#endif
48
49/* 2014-08-02 workaround for broken MinGW compiler.
50 * Oddly, only TRACE is mapped to trace - the other -D's are okay.
51 * suggest TDM as an alternative.
52 */
53#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
54
55#ifdef trace
56#undef trace
57#define TRACE
58#endif
59
60#endif	/* broken compiler */
61
62#endif	/* MingW */
63
64/*
65 * For reentrant code, we map the various global variables into SCREEN by
66 * using functions to access them.
67 */
68#define NCURSES_PUBLIC_VAR(name) @NCURSES_WRAP_PREFIX@##name
69#define NCURSES_WRAPPED_VAR(type,name) extern type NCURSES_PUBLIC_VAR(name)(void)
70
71/* no longer needed on cygwin or mingw, thanks to auto-import       */
72/* but this structure may be useful at some point for an MSVC build */
73/* so, for now unconditionally define the important flags           */
74/* "the right way" for proper static and dll+auto-import behavior   */
75#undef NCURSES_DLL
76#define NCURSES_STATIC
77
78#if defined(__CYGWIN__) || defined(_WIN32)
79#  if defined(NCURSES_DLL)
80#    if defined(NCURSES_STATIC)
81#      undef NCURSES_STATIC
82#    endif
83#  endif
84#  undef NCURSES_IMPEXP
85#  undef NCURSES_API
86#  undef NCURSES_EXPORT
87#  undef NCURSES_EXPORT_VAR
88#  if defined(NCURSES_DLL)
89/* building a DLL */
90#    define NCURSES_IMPEXP __declspec(dllexport)
91#  elif defined(NCURSES_STATIC)
92/* building or linking to a static library */
93#    define NCURSES_IMPEXP /* nothing */
94#  else
95/* linking to the DLL */
96#    define NCURSES_IMPEXP __declspec(dllimport)
97#  endif
98#  define NCURSES_API __cdecl
99#  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
100#  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
101#endif
102
103/* Take care of non-cygwin platforms */
104#if !defined(NCURSES_IMPEXP)
105#  define NCURSES_IMPEXP /* nothing */
106#endif
107#if !defined(NCURSES_API)
108#  define NCURSES_API /* nothing */
109#endif
110#if !defined(NCURSES_EXPORT)
111#  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
112#endif
113#if !defined(NCURSES_EXPORT_VAR)
114#  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
115#endif
116
117#endif /* NCURSES_DLL_H_incl */
118