Re: [问题] 请问C接口跟实作分开的作法

楼主: dzwei (Cout<< *p << \n ;)   2018-04-29 16:55:22
刚好最近有碰到,
目前也还在学习中,
刚好有点小心得,
有错误还恳请版上的大师们指正,
谢谢!
提个关键字跟板友分享一下
‘opaque pointer’
这跟C++的pimpl有87%像
以下code举例于维基百科
//=========================================
/* obj.h */
struct obj;
/*
* The compiler considers struct obj an incomplete type.
* Incomplete types can be used in declarations.
*/
size_t obj_size(void);
void obj_setid(struct obj *, int);
int obj_getid(struct obj *);
//
作者: KanzakiHAria (神崎・H・アリア)   2018-04-29 19:46:00
原文是说为什么要分开? 不分开会发生什么事?
作者: CoNsTaR ((const *))   2018-05-03 06:58:00
然后这篇的原文是说他有心得可以分享怎么做
作者: adrianshum (Alien)   2018-05-04 08:22:00
一来和前文无关,二来这根本就是(无用化了的)pimpl,三来C# 的 interface 根本就完全不是这回事(还是收回第二点。和pimpl 还是有差)

Links booklink

Contact Us: admin [ a t ] ucptt.com