Pergunta

I am trying to build an application in Xcode 3.2.4 and am getting the following linker error:

Undefined symbols:
  "___block_global_1", referenced from:
      ___block_holder_tmp_1.120 in foobarbaz.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I'm at a loss to explain what I've done in my source file that might be causing the error. I do have a block that I am defining as a global variable, like so:

typedef void(^error_block_t)(NSError* error);

error_block_t error_handler_s = ^void(NSError* error)
{
    //...
}

This block is defined in an empty namespace in the source (I'm compiling Objective-C++.) Everything compiles without error.

Update: Moving the block to be a local variable for the routine that references it is a viable (though not preferred) workaround.

What gives?

Foi útil?

Solução 2

At this point I believe this issue to be a bug.

Outras dicas

If the error_handler_s is not intended to be exported, you could make it static as another workaround.

namespace {
  ...
  static error_block_t error_handler_s = ^void(NSError* error) { ... };
  ...
}

Otherwise, I believe this is a bug in gcc.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top