zoukankan      html  css  js  c++  java
  • 全局变量的声明和定义 以及dll中全局变量的导出

    声明全局变量
    global_variable.h文件中
    #ifndef   global_variable_H  
    #define   global_variable_H
       extern int selectColumnResult;  
       extern CString strColumn[100];  
    #endif   //global_variable_H


    global_variable.cpp中
       int selectColumnResult;   
       CString strColumn[100];  
    然后在要用到全局变量 的cpp文件中#include "global_variable.h",可以
    将所有的全局变量弄到这个一个文件中。
    如果是vc++的话也可以直接都写在stdafx.h和stdafx.pp中。

    ====================================================

    全局变量导出 要封装的dll
    global_variable.h文件中
    #ifndef   global_variable_H  
    #define   global_variable_H
       extern "C" _declspec(dllexport) int selectColumnResult;    
       extern "C" _declspec(dllexport) CString strColumn[100];  
    #endif   //global_variable_H


    global_variable.cpp中
       int selectColumnResult;   
       CString strColumn[100];  

    封装后在proc.cpp中调用

    #pragma comment(lib,"global_variable.lib")

    extern "C" _declspec(dllimport) int selectColumnResult;   //列的数量
    extern "C" _declspec(dllimport) CString strColumn[100];   //列名

    在dll导出全局变量的方式和导出函数的方式完全一致。

  • 相关阅读:
    如何处理请求返回的二进制数据流转化成xlsx文件?
    iview 表单验证不通过问题?
    如何发布一个npm包?
    async 与 await
    数据库事务的四个基本特征以及事务的隔离级别
    遍历Map的四种方式
    HashMap详解
    HashMap和Hashtable的区别
    java中的堆、栈和常量池简介
    Spring IOC(转载)
  • 原文地址:https://www.cnblogs.com/yuzhould/p/4455029.html
Copyright © 2011-2022 走看看