Skip to content

Instantly share code, notes, and snippets.

@garrettsickles
Last active August 30, 2017 03:47
Show Gist options
  • Save garrettsickles/f769ef42de3732f84a9ff10d8f044824 to your computer and use it in GitHub Desktop.
Save garrettsickles/f769ef42de3732f84a9ff10d8f044824 to your computer and use it in GitHub Desktop.
Cross Platform API Declaration (C, C++)
// --------------------------------------------------------------- //
// Need To Know
// _MSC_VER: Microsoft C/C++ Compiler
// DLL_EXPORT: Defined when compiling to a DLL (DynamicLibrary)
// STATIC_EXPORT: Defined when compiling to a LIB (StaticLibrary)
// --------------------------------------------------------------- //
// Microsoft C/C++ Compiler (MSVC)
#if defined(_MSC_VER)
#if defined(DLL_EXPORT)
// Compiling to DynamicLibrary (DLL)
#define API __declspec(dllexport)
#else
// Otherwise...
#define API
#endif
// If we are non MSVC (Export by default)
#else
#define API
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment