Clang's C Blocks on Linux

40 views
Skip to first unread message

Kai Baker

unread,
Apr 7, 2017, 1:31:25 PM4/7/17
to collexion
clang added something called blocks to C. It is very intriguing but I don't have an Apple computer. I know there's a package for clang blocks on Ubuntu. Is there a package for other distributions? Perhaps something from source I can compile?

kai

Paul Eberhart

unread,
Apr 7, 2017, 11:23:17 PM4/7/17
to coll...@googlegroups.com
Oh neat, closures for C, I've seen people hack them various ways but didn't know there were any widely-supported compiler extensions.  

The 30-second test makes me think almost all modern clang builds support it, but don't have it in the default flags so you have to give it -fblocks to enable (Example from the machine I'm on, tested via dumb c preprocessor trick): 

[pappp@Talaiot ~ $]cat testblocks.c 
#if __has_extension(blocks)
#pragma message "Clang built with blocks extension"
#else
#pragma message "Clang NOT built with blocks extension"
#endif

int main()
{
return 0;
}
[pappp@Talaiot ~ $]clang testblocks.c 
testblocks.c:4:11: warning: Clang NOT built with blocks extension
      [-W#pragma-messages]
         #pragma message "Clang NOT built with blocks extension"
                 ^
1 warning generated.
[pappp@Talaiot ~ $]clang -fblocks testblocks.c 
testblocks.c:2:10: warning: Clang built with blocks extension
      [-W#pragma-messages]
        #pragma message "Clang built with blocks extension"
                ^
1 warning generated.
[pappp@Talaiot ~ $]clang -v
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/6.3.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.3.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64


On Fri, Apr 7, 2017 at 1:31 PM, Kai Baker <eigen...@gmail.com> wrote:
clang added something called blocks to C. It is very intriguing but I don't have an Apple computer. I know there's a package for clang blocks on Ubuntu. Is there a package for other distributions? Perhaps something from source I can compile?

kai

--
You received this message because you are subscribed to the Google Groups "Collexion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to collexion+unsubscribe@googlegroups.com.
To post to this group, send email to coll...@googlegroups.com.
Visit this group at https://groups.google.com/group/collexion.
For more options, visit https://groups.google.com/d/optout.



--
Paul Selegue Eberhart (PAPPP) - http://www.pappp.net/
Messages from this account may be in regard to PAPP...@gmail.com, pse...@uky.edu or pse...@engr.uky.edu.
Reply all
Reply to author
Forward
0 new messages