test_test
/* com_com.h */
#ifndef _COM_COM_H
#define _COM_COM_H
#define COMP_CALL /* __cdecl */
#define interface struct
#define DECLARE_INTERFACE(iface) \
struct iface##Vtbl; \
interface iface { \
struct iface##Vtbl * lpVtbl; \
}; \
typedef interface iface iface; \
typedef iface * P##iface;\
struct iface##Vtbl
#define METHOD(method) ULONG (COMP_CALL * method)
#define METHOD_(type,method) type (COMP_CALL * method)
#endif /* _COM_COM_H */
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
/* makefile */
COM_INCS = -Iinclude
COM_CFLG = -g -Wall
COM_SRCS = src/com_fun.c src/test_com.c
TEST:
gcc -o $@ $(COM_SRCS) $(COM_INCS) $(COM_CFLG)
clean:
rm TEST
/* com_fun.c */
#include <stdio.h>
#include "com_fun.h"
/* Function declartion */
int testHelloCProgram(char *pszVal);
int testHelloCPlusPlus(char *pszVal);
int testHelloJava(char *pszVal);
struct IIF_COMMON_TESTVtbl g_ComTestInterface =
{
testHelloCProgram,
testHelloCPlusPlus,
testHelloJava,
};
int testHelloCProgram(char *pszVal)
{
printf("[C]%s\n", pszVal);
return 0;
}
int testHelloCPlusPlus(char *pszVal)
{
printf("[CPP]%s\n", pszVal);
return 0;
}
int testHelloJava(char *pszVal)
{
printf("[JAVA]%s\n", pszVal);
return 0;
}
/* common.h */
#ifndef _COMMON_H
#define _COMMON_H
#include <stdio.h>
#include "com_com.h"
DECLARE_INTERFACE(IIF_COMMON_TEST)
{
METHOD_(int, pf_testHelloWorld)(char *pszVal);
METHOD_(int, pf_testHelloCProgram)(char *pszVal);
METHOD_(int, pf_testHelloCPlusPlus)(char *pszVal);
METHOD_(int, pf_testHelloJava)(char *pszVal);
};
#endif
/* test_com.c */
#include <stdio.h>
#include "com_fun.h"
extern struct IIF_COMMON_TESTVtbl g_ComTestInterface;
int main(int argc, char *argv[])
{
char * pszMsg = "Great Module";
g_ComTestInterface.pf_testHelloCPlusPlus(pszMsg);
return 0;
}