zoukankan      html  css  js  c++  java
  • C++ 导入导出

    几种方式汇总:

    方式一:


    #ifdef _MSC_VER
      #ifdef FBC_STATIC
        #define FBC_API
      #elif defined FBC_EXPORT
        #define FBC_API __declspec(dllexport)
      #else
        #define FBC_API __declspec(dllimport)
      #endif
    #endif

    链接:https://blog.csdn.net/fengbingchun/article/details/78825004

    方式二:

    #ifdef DLLEXPORT_EXPORTS
    #define DLLEXPORT_API __declspec(dllexport)
    #else
    #define DLLEXPORT_API __declspec(dllimport)
    #endif
    链接:https://www.cnblogs.com/chengbing2011/p/4084125.html

    方式三:

    可以省略dllimport???

    但MSDN文档里面,对于 __declspec(dllimport)的说明让人感觉有点奇怪,先来看看MSDN里面是怎么说的:

              不使用 __declspec(dllimport)也能正确编译代码,但使用 __declspec(dllimport) 使编译器可以生成更好的代码。编译器之所以能够生成更好的代码,是因为它可以确定函数是否存在于 DLL 中,这使得编译器可以生成跳过间接寻址级别的代码,而这些代码通常会出现在跨DLL 边界的函数调用中。但是,必须使用 __declspec(dllimport) 才能导入 DLL 中使用的变量。

          使用__declspec(dllimport)可以生成更好的代码

      #ifdef DLL_EXPORTS 

        #define SIMPLE_CLASS_EXPORT__declspec(dllexport) 

      #else

        #define SIMPLE_CLASS_EXPORT

      #endif

    链接:https://blog.csdn.net/huangyimo/article/details/81748939

      

    方式四:

      

      #ifdef _MSC_VER
        #ifdef GENICAM_API_DLL_BUILD
          #define GENICAM_API _declspec(dllexport)
        #elif defined GENICAM_API_DLL_USE
          #define GENICAM_API _declspec(dllimport)
        #else
          #define GENICAM_API
      #endif
      #elif defined __GNUC__
        #define GENICAM_API
      #else
        #define GENICAM_API
      #endif

      摘录于某相机SDK头文件

  • 相关阅读:
    pinpoint改造支持查询
    pinpoint本地开发——agent
    pinpoint本地开发——collector
    pinpoint本地开发-web模块
    第一个Vert.x程序
    ls bash: cannot create temp file for here-document: No space left on device
    hadoop磁盘空间不均衡的解决办法
    dubbo监控活跃线程数
    mac安装软件运行提示「xxx.app已损坏,打不开.你应该将它移到废纸篓」的解决办法
    python拆分excel脚本
  • 原文地址:https://www.cnblogs.com/JFHS/p/14464858.html
Copyright © 2011-2022 走看看