gpt4 book ai didi

c、struct之后的函数定义

转载 作者:太空狗 更新时间:2023-10-29 16:07:29 25 4
gpt4 key购买 nike

  675  * Check the validity of an ACL for a file.
676 */
677 int
678 ufs_aclcheck(ap)
679 struct vop_aclcheck_args /* {
680 struct vnode *vp;
681 acl_type_t type;
682 struct acl *aclp;
683 struct ucred *cred;
684 struct thread *td;
685 } */ *ap;
686 {
687
688 if ((ap->a_vp->v_mount->mnt_flag & (MNT_ACLS | MNT_NFS4ACLS)) == 0)
689 return (EOPNOTSUPP);
690
691 if (ap->a_type == ACL_TYPE_NFS4)
692 return (ufs_aclcheck_nfs4(ap));
693
694 return (ufs_aclcheck_posix1e(ap));
695 }
696
697 #endif /* !UFS_ACL */

此代码来自Freebsd UFS源码。这个函数看起来很奇怪。在函数名称之后,定义了一个结构。这是怎么回事?谢谢

最佳答案

这是一种编写 C 函数的旧风格,您可以在其中定义如下函数:

void foo(a)  /* Function and its arguments */
int a; /* Define the type of the arguments */
{
// Function body
}

删除注释后,函数中的内容:

int ufs_aclcheck(ap)
struct vop_aclcheck_args * ap;
{
// Function body
}

关于c、struct之后的函数定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22993255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com