首页 > 编程语言 >跨平台C++ DLL导出宏

跨平台C++ DLL导出宏

时间:2022-12-23 16:36:45浏览次数:46  
标签:__ DECL C++ DLL 跨平台 endif shared define

#pragma once

#if defined(__GNUC__)
#define _DEPRECATED_ __attribute__((deprecated))
#define _FORCE_INLINE_ __attribute__((always_inline))
#elif defined(_MSC_VER)
#define _DEPRECATED_
#define _FORCE_INLINE_ __forceinline
#else
#define _DEPRECATED_
#define _FORCE_INLINE_ inline
#endif

/*
  Windows import/export and gnu http://gcc.gnu.org/wiki/Visibility
  macros.
 */
#if defined(_MSC_VER)
    #define DLL_IMPORT __declspec(dllimport)
    #define DLL_EXPORT __declspec(dllexport)
    #define DLL_LOCAL
#elif __GNUC__ >= 4
    #define DLL_IMPORT __attribute__ ((visibility("default")))
    #define DLL_EXPORT __attribute__ ((visibility("default")))
    #define DLL_LOCAL  __attribute__ ((visibility("hidden")))
#else
    #define DLL_IMPORT
    #define DLL_EXPORT
    #define DLL_LOCALs
#endif

// Ignore warnings about import/exports when deriving from std classes.
#ifdef _MSC_VER
  #pragma warning(disable: 4251)
  #pragma warning(disable: 4275)
#endif

// Import/export for windows dll's and visibility for gcc shared libraries.


#ifdef BUILD_SHARED_LIBS   // project is being built around shared libraries
    #ifdef CLASS_EXPORTS   // we are building a shared lib/dll
        #define CLASS_DECL DLL_EXPORT
    #else                  // we are using shared lib/dll
        #define CLASS_DECL DLL_IMPORT
    #endif

    #ifdef FUNC_EXPORTS    // we are building a shared lib/dll
        #define FUNC_DECL DLL_EXPORT
    #else                  // we are using shared lib/dll
        #define FUNC_DECL DLL_IMPORT
    #endif
#else                      // project is being built around static libraries
    #define CLASS_DECL
    #define FUNC_DECL
#endif

 

标签:__,DECL,C++,DLL,跨平台,endif,shared,define
From: https://www.cnblogs.com/djh5520/p/17000977.html

相关文章

  • c++随笔测试(Corner of cpp)
    在c++17下,程序的输出是什么?(有可能编译出错,有可能输出未知,有可能是未定义行为)点击查看代码#include<iostream>voidfoo(unsignedint){std::cout<<"uint";}voidfo......
  • C++中map用法详解
    Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1.map最基本的构造函数;map<string,......
  • c++ 读取Ini文件
    头文件#include<atlstr.h> C++读取INI文件-疯封风-博客园(cnblogs.com)......
  • 获取本机内网、外网ip(C++)
    基础知识  电脑在局域网内,通过网关/路由器连接到Internet则ip分为内网ip、外网ip。通过ipconfig得到的为局域网ip。电脑直接拨号连接等,则本机通过ipconfig得到的就......
  • C++提取出std::map中的key集合
    std::map<std::string,uint32_t>dictionarystd::set<conststd::string*>keySet;//std::back_inserter(keyVector)std::transform(dictionary.begin(),dictiona......
  • c++通过DPI连接达梦数据库
    通过ODBC连接上数据库后,同事让我换内网电脑开发,又换了数据库给我,结果怎么都连不上数据库,又尝试了DPI连接达梦数据库的方式,连接上了,记录如下。连接代码#include"StdAfx.......
  • Intellij Java JNI 调用 C++
    也可以用JNA,但性能没有JNI 好。JNA的Demo没有做,可以参考(​​https://www.bilibili.com/video/BV1xU4y1F7Ep/?spm_id_from=autoNext​​)JNI 参考(​​https://www.runoob.......
  • 组合模式javac++
    本次实验属于模仿型实验,通过本次实验学生将掌握以下内容:1、理解组合模式的动机,掌握该模式的结构;2、能够利用组合模式解决实际问题。 [实验任务一]:组合模式用透明组合......
  • C++学习---cstdio的源码学习分析10-改变文件流文件流buffer函数setvbuf
    cstdio中的文件访问函数stdio.h中定义了一系列文件访问函数(fopen,fclose,fflush,freopen,setbuf,setvbuf),接下来我们一起来分析一下setvbuf对应的源码实现。-fopen:打开文件-......
  • 观察者模式——C++实现
    问题截图:当股票的价格上涨或下降5%时,会通知持有该股票的股民,当股民听到价格上涨的消息时会买股票,当价格下降时会大哭一场。类图:  代码:#include<iostream>#includ......