为什么.c文件可以包含块? [英] Why can .c files contain blocks?

查看:100
本文介绍了为什么.c文件可以包含块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为block是Objective-C的功能.最近,我将代码块添加到了一些C源文件中,并且发现它可以正常编译.

I think block is the Objective-C feature. Recently I am adding the block to some C source file and I found it just compile OK.

对于* .c文件,我感到困惑,编译器(Clang)是否应该将其视为纯C文件,为什么它可以允许阻塞?

I get confused, for *.c file, should the compiler(Clang) consider it as the pure C file, why it can permit block?

推荐答案

实际上Clang引入了块

Actually Clang introduces blocks

到C,以及扩展到Objective-C,C ++和Objective-C ++

to C and, by extension, Objective-C, C++, and Objective-C++

您可以在概述中阅读此处.

当然,使用块会使您的源代码与C11标准不兼容,但是,您知道,只要您的代码仅适用于Mac OS X ...

Of course, using blocks makes your source incompatible with C11 standard but, you know, as long as your code is for Mac OS X only...

编辑:不知道,GCC中也提供了块.

EDIT: Blocks are also available in GCC, didn't know about it.

这篇关于为什么.c文件可以包含块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆