gpt4 book ai didi

兼容类型和参数类型限定符

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

这两个声明的类型是兼容类型吗?

void f(char *, char *);
void f(char *restrict, char *restrict);

或类似的:

void g(char *);
void g(char *const);

我很难在标准中找到涵盖该问题的任何内容。我最感兴趣的话题是,在省略 restrict 关键字的情况下,手动为函数制作原型(prototype)是否有效,其中实际类型可能具有 restrict 限定的参数,具体取决于 C 的版本或正在使用的其他库的版本。

最佳答案

它们是兼容的:

(C99, 6.7.5.3 Function declarators (including prototypes) p15) "[...] (In the determination of type compatibility and of a composite type, each parameter declared with function or array type is taken as having the adjusted type and each parameter declared with qualified type is taken as having the unqualified version of its declared type.)"

关于兼容类型和参数类型限定符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18215686/

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