免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1358 | 回复: 4
打印 上一主题 下一主题

test_test [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-05-10 19:51 |只看该作者 |倒序浏览
/* 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 */

论坛徽章:
0
2 [报告]
发表于 2011-05-10 19:52 |只看该作者
/* 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;
}

论坛徽章:
0
3 [报告]
发表于 2011-05-10 19:53 |只看该作者
/* 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

论坛徽章:
0
4 [报告]
发表于 2011-05-10 19:53 |只看该作者
/* 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;
}

论坛徽章:
0
5 [报告]
发表于 2011-05-10 19:54 |只看该作者
/* 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP