• VS2008 error C2470


    error C2470: '***类' : looks like a function definition, but there is no parameter list; skipping apparent body。

    操作过程:由于***类 是我自己封装的dll,在编译该库的时候没有此错误,但是在需要用的工程里导入该库的时候在编译的时候报了此错误。

    原因:找了会发现是我在dll库工程声明宏的时候声明在了stdafx.h里面,

    #ifdef POTATO_EXPORTS
    #define POTATOEXPORT _declspec(dllexport)
    #else
    #define POTATOEXPORT _declspec(dllimport)
    #endif

    在编译该dll工程的时候 这个stdafx.h文件是能找到了 因此编译dll库的时候不会报错,但是将该dll加载到所需工程的时候,由于stdafx.h头文件包含在dll工程里,在别的工程里就找不到#define POTATOEXPORT _declspec(dllimport) 所以会报looks like a function definition, but there is no parameter list; skipping apparent body。


    解决办法:在dll工程里新添加一个头文件,然后将此宏

    #ifdef POTATO_EXPORTS
    #define POTATOEXPORT _declspec(dllexport)
    #else
    #define POTATOEXPORT _declspec(dllimport)
    #endif

    放在该头文件里,最后在你需要导出的类的头文件里包含此头文件再编译dll工程,替换所需工程里的dll,同步头文件以及lib,然后编译所需工程,通过。问题解决。

  • 相关阅读:
    .net将动态页面(aspx)生成静态页面htm | html
    js复制Code
    发送Email 附件打包,
    PC大屏自适应 简洁版
    PC大屏自适应
    Java 常见类型转换
    二叉树的四种遍历
    C语言代码质量保证
    System.ComponentModel.Component入门
    旧版MFC自定义CFileDialog Win7中扩展无显示 解决
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3275654.html
Copyright © 2020-2023  润新知