Clang has a very cool extension named block bringing true lambda function mechanism to C. Compared to block, gcc's nested functions are quite limited. However, trying to compile a trivial program c.c
:
#include <stdio.h>
int main() {
void (^hello)(void) = ^(void) {
printf("Hello, block!
");
};
hello();
return 0;
}
with clang -fblocks c.c
, I got
/usr/bin/ld.gold: /tmp/cc-NZ7tqa.o: in function __block_literal_global:c.c(.rodata+0x10): error: undefined reference to '_NSConcreteGlobalBlock'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
seems I should use clang -fblocks c.c -lBlocksRuntime
, but then I got
/usr/bin/ld.gold: error: cannot find -lBlocksRuntime
(the rest is the same as above)
Any hints?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…