这个C函数语法是什么?

这个C函数语法是什么?,第1张

概述参见英文答案 > What does this dot syntax mean in the Pebble watch development tutorial?                                     2个 我说我在c语言编程方面有中级经验,但是我从来没有见过这个语法用来创建函数.这让我想起了JQuery事件的语法.总的来说,我想详细解释这是什么以及替代语法可能是 参见英文答案 > What does this dot syntax mean in the Pebble watch development tutorial? 2个
我说我在c语言编程方面有中级经验,但是我从来没有见过这个语法用来创建函数.这让我想起了Jquery事件的语法.总的来说,我想详细解释这是什么以及替代语法可能是什么.我可以更好地阅读更多有关此内容的链接也很棒.
// Set handlers to manage the elements insIDe the Window window_set_window_handlers(s_main_window,(WindowHandlers) {    .load = main_window_load,.unload = main_window_unload  });

这是Pebble WatchApp tutorial的代码片段.

解决方法 这是一个使用复合文字的函数调用.它相当于以下内容:
WindowHandlers temp = {    .load = main_window_load,.unload = main_window_unload  };window_set_window_handlers(s_main_window,temp );

上面还使用了指定的初始值设定项,您可以在其中指定要按名称初始化的字段.

假设WindowHandlers只包含该顺序的加载和卸载,则上述内容相当于:

WindowHandlers temp = { main_window_load,main_window_unload };window_set_window_handlers(s_main_window,temp );

C standard更详细地介绍了这些内容.

从6.5.2.5节:

4@H_419_26@ A postfix Expression that consists of a parenthesized type
name followed by a brace-enclosed List of initializers is a
compound literal. It provIDes an unnamed object whose value is
given by the initializer List.

9@H_419_26@ EXAMPLE 1 The file scope deFinition

06002

initializes p to point to the first element of an array of
two ints,the first having the value two and the second,four.
The Expressions in this compound literal are required to be
constant. The unnamed object has static storage duration.

从第6.7.8节开始:

1@H_419_26@

06003

7@H_419_26@ If a designator has the form

06004

then the current object (defined below) shall have structure
or union type and the IDentifIEr shall be the name of a member of
that type.

34@H_419_26@ EXAMPLE 10 Structure members can be initialized to nonzero values without depending on their order:

06005

总结

以上是内存溢出为你收集整理的这个C函数语法是什么?全部内容,希望文章能够帮你解决这个C函数语法是什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1236443.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存