我有一种情况需要在Doxygen中记录bsearch()签名。这个签名看起来像这样:
void * __cdecl bsearch (
const void *key,
const void *base,
size_t num,
size_t width,
int(__cdecl *compare)(const void *, const void *)
)
我遇到的问题是如何为指针*比较组成@param命令,因为Doxygen抱怨" 参数'比较'命令@param在bsearch的参数列表中找不到"在我抛出的一切。
这是一个独立的实现,因此它不依赖于库签名,但我想是否这样做:
typedef int(__cdecl *pcompare)(const void *, const void *);
将签名更改为pcompare比较使用标准签名的调用者会遇到类型问题。
我愿意接受任何解决方案,让我能够在没有Doxygen警报的情况下记录下来。
答案 0 :(得分:5)
however I am thinking if I did:
typedef int(__cdecl *pcompare)(const void *, const void *);
changing the signature to
pcompare compare
that callers using the standard signature would have a type problem.
You should have tried it before giving up. typedef
does not define a new type, it just creates a new identifier for a complex type. The resulting signatures are identical.
Be careful though, because neither of the forms shown are the correct signature. To declare A C runtime library function like bsearch
you need extern "C"
. (and so would the function pointer typedef -- language linkage is part of the function type)
All of that said, just setting __cdecl
as a predefined macro in your doxygen config would probably be sufficient to allow it to parse all of these variations, including the ones with a complex set of tokens specifying the parameter type.
答案 1 :(得分:0)
typedef没有问题。
无论如何你都应该使用它 - 它更清晰易读。