相关疑难解决方法(0)

Linux上的编译器是否支持Objective-C块?

如何在linux上编译以下代码?使用Ubuntu 10.10(Maverick Meerkat).

#include <stdio.h>
#include <stdlib.h>

int main() {
  void (^block)() = ^{
    printf("Hello world");
  };
  block();
}

我试过了:

gcc -x objective-c t.c 

得到了:

t.c: In function 'main':
t.c:5: error: expected identifier or '(' before '^' token

任何关于如何使这项工作的指导表示赞赏.根据反馈编辑问题,谢谢.

linux objective-c objective-c-blocks

6
推荐指数
1
解决办法
2982
查看次数

您需要使用块链接哪些库来进行clang程序

我发现(下面)我在编译使用块的代码时需要使用-fblocks.

我需要链接哪个库让链接器解析_NSConcreteStackBlock?(在Ubuntu 9.10 AMD64上.)

chris@chris-desktop:~$ clang ctest.c 

ctest.c:3:25: error: blocks support disabled - compile with -fblocks or pick a
      deployment target that supports them
void call_a_block(void (^blockptr)(int)) {
                        ^
ctest.c:11:19: error: blocks support disabled - compile with -fblocks or pick a
      deployment target that supports them
    call_a_block( ^(int y) { 
                  ^
2 diagnostics generated.
chris@chris-desktop:~$ clang ctest.c -fblocks
/tmp/cc-4sPSeO.o: In function `main':
ctest.c:(.text+0x79): undefined reference to `_NSConcreteStackBlock'
collect2: ld returned 1 exit status
clang: error: linker command failed with exit …
Run Code Online (Sandbox Code Playgroud)

ubuntu llvm clang objective-c-blocks

5
推荐指数
2
解决办法
2816
查看次数

为匿名函数创建C语言附加组件是否可行?

我知道C编译器能够获取独立的代码,并针对它们所针对的特定系统从中生成独立的shellcode。

例如,在中给出以下内容anon.c

int give3() {
    return 3;
}
Run Code Online (Sandbox Code Playgroud)

我可以跑

gcc anon.c -o anon.obj -c
objdump -D anon.obj
Run Code Online (Sandbox Code Playgroud)

这给了我(在MinGW上):

anon1.obj:     file format pe-i386


Disassembly of section .text:

00000000 <_give3>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   b8 03 00 00 00          mov    $0x3,%eax
   8:   5d                      pop    %ebp
   9:   c3                      ret    
   a:   90                      nop
   b:   90                      nop
Run Code Online (Sandbox Code Playgroud)

所以我可以像这样制作main:

main.c

#include <stdio.h>
#include <stdint.h>

int main(int argc, char **argv)
{
    uint8_t shellcode[] = {
        0x55,
        0x89, 0xe5,
        0xb8, …
Run Code Online (Sandbox Code Playgroud)

c assembly lambda functional-programming shellcode

0
推荐指数
1
解决办法
181
查看次数