1717
1818#ifdef DOCOPT_HEADER_ONLY
1919 #define DOCOPT_INLINE inline
20- #define DOCOPTAPI
20+ #define DOCOPT_API
2121#else
2222 #define DOCOPT_INLINE
2323
24- // On Windows, export certain symbols so they are available
25- // to users of docopt.dll (shared library).
26- #ifdef WIN32
24+ // With Microsoft Visual Studio, export certain symbols so they
25+ // are available to users of docopt.dll (shared library). The DOCOPT_DLL
26+ // macro should be defined if building a DLL (with Visual Studio),
27+ // and by clients using the DLL. The CMakeLists.txt and the
28+ // docopt-config.cmake it generates handle this.
29+ #ifdef DOCOPT_DLL
30+ // Whoever is *building* the DLL should define DOCOPT_EXPORTS.
31+ // The CMakeLists.txt that comes with docopt does this.
32+ // Clients of docopt.dll should NOT define DOCOPT_EXPORTS.
2733 #ifdef DOCOPT_EXPORTS
28- #define DOCOPTAPI __declspec (dllexport)
34+ #define DOCOPT_API __declspec (dllexport)
2935 #else
30- #define DOCOPTAPI __declspec (dllimport)
36+ #define DOCOPT_API __declspec (dllimport)
3137 #endif
3238 #else
33- #define DOCOPTAPI
39+ #define DOCOPT_API
3440 #endif
3541#endif
3642
@@ -61,7 +67,7 @@ namespace docopt {
6167 // / @throws DocoptExitHelp if 'help' is true and the user has passed the '--help' argument
6268 // / @throws DocoptExitVersion if 'version' is true and the user has passed the '--version' argument
6369 // / @throws DocoptArgumentError if the user's argv did not match the usage patterns
64- std::map<std::string, value> DOCOPTAPI docopt_parse (std::string const & doc,
70+ std::map<std::string, value> DOCOPT_API docopt_parse (std::string const & doc,
6571 std::vector<std::string> const & argv,
6672 bool help = true ,
6773 bool version = true ,
@@ -74,7 +80,7 @@ namespace docopt {
7480 // / * DocoptExitHelp - print usage string and terminate (with exit code 0)
7581 // / * DocoptExitVersion - print version and terminate (with exit code 0)
7682 // / * DocoptArgumentError - print error and usage string and terminate (with exit code -1)
77- std::map<std::string, value> DOCOPTAPI docopt (std::string const & doc,
83+ std::map<std::string, value> DOCOPT_API docopt (std::string const & doc,
7884 std::vector<std::string> const & argv,
7985 bool help = true ,
8086 std::string const & version = {},
0 commit comments