Skip to content

Instantly share code, notes, and snippets.

@doevelopper
Last active September 2, 2022 09:21
Show Gist options
  • Save doevelopper/0c84cd6b1fd1d21353123166792a4d0d to your computer and use it in GitHub Desktop.
Save doevelopper/0c84cd6b1fd1d21353123166792a4d0d to your computer and use it in GitHub Desktop.

cpp lnaguage source code Visibility.hpp

#include <functional>

#if defined(__clang__)
#define SC_SYMBOL_EXPORT __attribute__((__visibility__("default")))
#define SC_SYMBOL_IMPORT
#elif defined(__GNUC__)
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
  #define SYMBOL_EXPORT __attribute__((__dllexport__))
  #define SYMBOL_IMPORT __attribute__((__dllimport__))
#else
  #define SYMBOL_EXPORT __attribute__((__visibility__("default")))
  #define SYMBOL_IMPORT
#endif
#elif defined(_MSC_VER)
  #define SYMBOL_EXPORT __declspec(dllexport)
  #define SYMBOL_IMPORT __declspec(dllimport)
#endif

#ifdef SHADER_CONDUCTOR_SOURCE
  #define _API SC_SYMBOL_EXPORT
#else
  #define _API SC_SYMBOL_IMPORT
#endif
// Generic helper definitions for shared library support
#if defined _WIN32 || defined __CYGWIN__
      #define FOX_HELPER_DLL_IMPORT __declspec(dllimport)
      #define FOX_HELPER_DLL_EXPORT __declspec(dllexport)
      #define FOX_HELPER_DLL_LOCAL
#else
    #if __GNUC__ >= 4
        #define FOX_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
        #define FOX_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
        #define FOX_HELPER_DLL_LOCAL  __attribute__ ((visibility ("hidden")))
    #else
        #define FOX_HELPER_DLL_IMPORT
        #define FOX_HELPER_DLL_EXPORT
        #define FOX_HELPER_DLL_LOCAL
    #endif
#endif

// Now we use the generic helper definitions above to define FOX_API and FOX_LOCAL.
// FOX_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build)
// FOX_LOCAL is used for non-api symbols.

#ifdef FOX_DLL // defined if FOX is compiled as a DLL
    #ifdef FOX_DLL_EXPORTS // defined if we are building the FOX DLL (instead of using it)
        #define FOX_API FOX_HELPER_DLL_EXPORT
    #else
        #define FOX_API FOX_HELPER_DLL_IMPORT
    #endif // FOX_DLL_EXPORTS

    #define FOX_LOCAL FOX_HELPER_DLL_LOCAL

#else // FOX_DLL is not defined: this means FOX is a static lib.
    #define FOX_API
    #define FOX_LOCAL
#endif // FOX_DLL

C language source code Visibility.h

/* C++ needs to know that types and declarations are C, not C++.  */
#ifdef   __cplusplus
# define __BEGIN_DECLS  extern "C" {                                            
# define __END_DECLS }
#else
# define __BEGIN_DECLS
# define __END_DECLS
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment