test_test

发布于 2022-10-15 07:21:52 字数 946 浏览 15 评论 0

/* 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

妄司 2022-10-22 07:21:53

/* 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

苍白女子 2022-10-22 07:21: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;
}

甜扑 2022-10-22 07:21:52

/* 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

似最初 2022-10-22 07:21:52

/* 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;
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文