xref: /dflybsd-src/lib/libncurses/include/ncurses_dll.h (revision 2ff0cc302e82d6175cbe81dba2f5318e19834254)
1946ecb11SJan Lentfer /****************************************************************************
2*2ff0cc30SDaniel Fojt  * Copyright 2018,2020 Thomas E. Dickey                                     *
3*2ff0cc30SDaniel Fojt  * Copyright 2009,2014 Free Software Foundation, Inc.                       *
4946ecb11SJan Lentfer  *                                                                          *
5946ecb11SJan Lentfer  * Permission is hereby granted, free of charge, to any person obtaining a  *
6946ecb11SJan Lentfer  * copy of this software and associated documentation files (the            *
7946ecb11SJan Lentfer  * "Software"), to deal in the Software without restriction, including      *
8946ecb11SJan Lentfer  * without limitation the rights to use, copy, modify, merge, publish,      *
9946ecb11SJan Lentfer  * distribute, distribute with modifications, sublicense, and/or sell       *
10946ecb11SJan Lentfer  * copies of the Software, and to permit persons to whom the Software is    *
11946ecb11SJan Lentfer  * furnished to do so, subject to the following conditions:                 *
12946ecb11SJan Lentfer  *                                                                          *
13946ecb11SJan Lentfer  * The above copyright notice and this permission notice shall be included  *
14946ecb11SJan Lentfer  * in all copies or substantial portions of the Software.                   *
15946ecb11SJan Lentfer  *                                                                          *
16946ecb11SJan Lentfer  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17946ecb11SJan Lentfer  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18946ecb11SJan Lentfer  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19946ecb11SJan Lentfer  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20946ecb11SJan Lentfer  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21946ecb11SJan Lentfer  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22946ecb11SJan Lentfer  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23946ecb11SJan Lentfer  *                                                                          *
24946ecb11SJan Lentfer  * Except as contained in this notice, the name(s) of the above copyright   *
25946ecb11SJan Lentfer  * holders shall not be used in advertising or otherwise to promote the     *
26946ecb11SJan Lentfer  * sale, use or other dealings in this Software without prior written       *
27946ecb11SJan Lentfer  * authorization.                                                           *
28946ecb11SJan Lentfer  ****************************************************************************/
29*2ff0cc30SDaniel Fojt /* $Id: ncurses_dll.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */
30946ecb11SJan Lentfer 
31946ecb11SJan Lentfer #ifndef NCURSES_DLL_H_incl
32946ecb11SJan Lentfer #define NCURSES_DLL_H_incl 1
33946ecb11SJan Lentfer 
34*2ff0cc30SDaniel Fojt /*
35*2ff0cc30SDaniel Fojt  * MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64.
36*2ff0cc30SDaniel Fojt  */
37*2ff0cc30SDaniel Fojt #if defined(__MINGW64__)
38*2ff0cc30SDaniel Fojt 
39*2ff0cc30SDaniel Fojt #ifndef _WIN64
40*2ff0cc30SDaniel Fojt #define _WIN64 1
41*2ff0cc30SDaniel Fojt #endif
42*2ff0cc30SDaniel Fojt 
43*2ff0cc30SDaniel Fojt #elif defined(__MINGW32__)
44*2ff0cc30SDaniel Fojt 
45*2ff0cc30SDaniel Fojt #ifndef _WIN32
46*2ff0cc30SDaniel Fojt #define _WIN32 1
47*2ff0cc30SDaniel Fojt #endif
48*2ff0cc30SDaniel Fojt 
493eec8774SJohn Marino /* 2014-08-02 workaround for broken MinGW compiler.
503eec8774SJohn Marino  * Oddly, only TRACE is mapped to trace - the other -D's are okay.
513eec8774SJohn Marino  * suggest TDM as an alternative.
523eec8774SJohn Marino  */
533eec8774SJohn Marino #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
543eec8774SJohn Marino 
553eec8774SJohn Marino #ifdef trace
563eec8774SJohn Marino #undef trace
573eec8774SJohn Marino #define TRACE
583eec8774SJohn Marino #endif
593eec8774SJohn Marino 
603eec8774SJohn Marino #endif	/* broken compiler */
61*2ff0cc30SDaniel Fojt 
623eec8774SJohn Marino #endif	/* MingW */
633eec8774SJohn Marino 
64ee39cac4SJohn Marino /*
65ee39cac4SJohn Marino  * For reentrant code, we map the various global variables into SCREEN by
66ee39cac4SJohn Marino  * using functions to access them.
67ee39cac4SJohn Marino  */
68ee39cac4SJohn Marino #define NCURSES_PUBLIC_VAR(name) _nc_##name
69ee39cac4SJohn Marino #define NCURSES_WRAPPED_VAR(type,name) extern type NCURSES_PUBLIC_VAR(name)(void)
70ee39cac4SJohn Marino 
71946ecb11SJan Lentfer /* no longer needed on cygwin or mingw, thanks to auto-import       */
72946ecb11SJan Lentfer /* but this structure may be useful at some point for an MSVC build */
73946ecb11SJan Lentfer /* so, for now unconditionally define the important flags           */
74946ecb11SJan Lentfer /* "the right way" for proper static and dll+auto-import behavior   */
75946ecb11SJan Lentfer #undef NCURSES_DLL
76946ecb11SJan Lentfer #define NCURSES_STATIC
77946ecb11SJan Lentfer 
78*2ff0cc30SDaniel Fojt #if defined(__CYGWIN__) || defined(_WIN32)
79946ecb11SJan Lentfer #  if defined(NCURSES_DLL)
80946ecb11SJan Lentfer #    if defined(NCURSES_STATIC)
81946ecb11SJan Lentfer #      undef NCURSES_STATIC
82946ecb11SJan Lentfer #    endif
83946ecb11SJan Lentfer #  endif
84946ecb11SJan Lentfer #  undef NCURSES_IMPEXP
85946ecb11SJan Lentfer #  undef NCURSES_API
86946ecb11SJan Lentfer #  undef NCURSES_EXPORT
87946ecb11SJan Lentfer #  undef NCURSES_EXPORT_VAR
88946ecb11SJan Lentfer #  if defined(NCURSES_DLL)
89946ecb11SJan Lentfer /* building a DLL */
90946ecb11SJan Lentfer #    define NCURSES_IMPEXP __declspec(dllexport)
91946ecb11SJan Lentfer #  elif defined(NCURSES_STATIC)
92946ecb11SJan Lentfer /* building or linking to a static library */
93946ecb11SJan Lentfer #    define NCURSES_IMPEXP /* nothing */
94946ecb11SJan Lentfer #  else
95946ecb11SJan Lentfer /* linking to the DLL */
96946ecb11SJan Lentfer #    define NCURSES_IMPEXP __declspec(dllimport)
97946ecb11SJan Lentfer #  endif
98946ecb11SJan Lentfer #  define NCURSES_API __cdecl
99946ecb11SJan Lentfer #  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
100946ecb11SJan Lentfer #  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
101946ecb11SJan Lentfer #endif
102946ecb11SJan Lentfer 
103946ecb11SJan Lentfer /* Take care of non-cygwin platforms */
104946ecb11SJan Lentfer #if !defined(NCURSES_IMPEXP)
105946ecb11SJan Lentfer #  define NCURSES_IMPEXP /* nothing */
106946ecb11SJan Lentfer #endif
107946ecb11SJan Lentfer #if !defined(NCURSES_API)
108946ecb11SJan Lentfer #  define NCURSES_API /* nothing */
109946ecb11SJan Lentfer #endif
110946ecb11SJan Lentfer #if !defined(NCURSES_EXPORT)
111946ecb11SJan Lentfer #  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
112946ecb11SJan Lentfer #endif
113946ecb11SJan Lentfer #if !defined(NCURSES_EXPORT_VAR)
114946ecb11SJan Lentfer #  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
115946ecb11SJan Lentfer #endif
116946ecb11SJan Lentfer 
117946ecb11SJan Lentfer #endif /* NCURSES_DLL_H_incl */
118