开发者社区> 问答> 正文

SP++3.0 编译问题?报错

@张明 你好,想跟你请教个问题(方便的话加QQ好友,我的QQ:8163210,谢谢!):

 SP++3.0 编译问题:

             你好,你编写的SP++3.0,我怎么不能直接在一个MFC扩展DLL里面编译使用呢? 例如下面的MFC DLL导出类里面(VS2010开发环境,工程路径已经正确包含了SP的头文件目录):

#pragma once
#define BOUNDS_CHECK
#include <iostream>
#include <convolution.h>
using namespace std;
using namespace splab;
typedef double  Type;
class AFX_EXT_CLASS  CMySp
{
public:
    CMySp(void);
    virtual ~CMySp(void);
};

编译文件报错:

1>------ 已启动生成: 项目: MFCDLL, 配置: Debug Win32 ------
1>  MySp.cpp
1>d:\software\develop\sp\sp++3.0\include\vector.h(181): warning C4003: “min”宏的实参不足
1>d:\software\develop\sp\sp++3.0\include\vector.h(181): error C2027: 使用了未定义类型“Type”
1>d:\software\develop\sp\sp++3.0\include\vector.h(181): error C2226: 语法错误 : 意外的“splab::Vector<Type>”类型
1>d:\software\develop\sp\sp++3.0\include\vector.h(181): error C2988: 不可识别的模板声明/定义
1>d:\software\develop\sp\sp++3.0\include\vector.h(181): error C2059: 语法错误:“)”
1>d:\software\develop\sp\sp++3.0\include\vector.h(182): warning C4003: “max”宏的实参不足
1>d:\software\develop\sp\sp++3.0\include\vector.h(182): error C2065: “Type”: 未声明的标识符
1>d:\software\develop\sp\sp++3.0\include\vector.h(182): error C2923: “splab::Vector”: 对于参数“Type”,“Type”不是有效的 模板 类型变量
1>d:\software\develop\sp\sp++3.0\include\vector.h(182): error C2988: 不可识别的模板声明/定义
1>d:\software\develop\sp\sp++3.0\include\vector.h(182): error C2059: 语法错误:“)”
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(632): warning C4003: “min”宏的实参不足
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(632): error C2027: 使用了未定义类型“Type”
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(632): error C2226: 语法错误 : 意外的“splab::Vector<Type>”类型
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(632): error C2988: 不可识别的模板声明/定义
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(632): error C2059: 语法错误:“)”
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(647): warning C4003: “max”宏的实参不足
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(647): error C2065: “Type”: 未声明的标识符
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(647): error C2923: “splab::Vector”: 对于参数“Type”,“Type”不是有效的 模板 类型变量
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(647): error C2988: 不可识别的模板声明/定义
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(647): error C2059: 语法错误:“)”
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(648): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>d:\software\develop\sp\sp++3.0\include\vector-impl.h(648): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========



展开
收起
爱吃鱼的程序员 2020-06-22 15:01:42 944 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    导出的数据成员不能包含STL数据结构。


    根据SP++3.0的描述,你没有必要把他编译进去DLL,也是不可能的,因为他是使用模板实现的。

    所以你在使用的时候直接包含头文件即可了。

    问题是我在一个扩展DLL里面想直接使用SP的函数进行计算啊,不是把SP编译成DLL,直接使用都不行啊。这个应该是没有问题的,估计是你头文件引用缺少了。。谁有直接在一个类里面调用SP模板函数的案例方法啊?在MFC扩展DLL不能编译SP++的模板接口原因(编译冲突),在MFC扩展DLL的stdafx.h头文件的这两行代码有关,注释掉就可以直接使用了:
    //#include<afxwin.h>        //MFC核心组件和标准组件

    //#include<afxext.h>        

    因此一般建议在常规DLL模块中调用SP++模板接口。

    这是因为在splab空间定义的max,min函数与stl中定义的max,min函数不一致导致的,建议在vector.h中紧跟包括的头文件之后加上#undefmax和#undefmin。

    添加后编译通过,谢谢~
    2020-06-22 15:01:59
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载