小编Avi*_*tta的帖子

将C .inc文件更改为.h和.cpp

我有一个用C编写的.inc文件.它包含一些带有实现的定义和方法签名.

.inc文件:

#define CONCAT(x,y)    x ## y
#define LCONCAT(x,y)  CONCAT(x,y)

#define DLIST          LCONCAT(LCONCAT(double_,LISTELEMENT),_list)
#define DELETEDFIRST   LCONCAT(delete_first_double_,LISTELEMENT)

int DELETEDFIRST (DLIST **first, DLIST **last);

int DELETEDFIRST (DLIST **first, DLIST **last)
{...}
Run Code Online (Sandbox Code Playgroud)

我想把它带到c ++.在我的.h文件中,我有define指令和方法签名(封装在命名空间中).在.cpp我只有方法实现.

.h文件

#define CONCAT(x,y)    x ## y
#define LCONCAT(x,y)  CONCAT(x,y)

#define DLIST          LCONCAT(LCONCAT(double_,LISTELEMENT),_list)
#define DELETEDFIRST   LCONCAT(delete_first_double_,LISTELEMENT)

namespace ListFunctions {
int DELETEDFIRST (DLIST **first, DLIST **last);
}
Run Code Online (Sandbox Code Playgroud)

.cpp文件

# include ListFunctions.h

namespace ListFunctions {
     int DELETEDFIRST (DLIST **first, DLIST **last) {...}
}
Run Code Online (Sandbox Code Playgroud)

我打算在开发我的模块时使用这些列表函数.在我的module.h中,我定义了一个类型double_ node _list(双端),在我的module.cpp中,我将LISTELEMENT定义为" node ",然后包含ListFunctions.h.但ListFunctions.cpp中的相同内容会导致编译错误:

..\ListFunctions.h(86): error …
Run Code Online (Sandbox Code Playgroud)

c c++

0
推荐指数
1
解决办法
2526
查看次数

标签 统计

c ×1

c++ ×1