Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Error in bnns.h - Missing ')'

Greetings!

I have an app that builds ad runs just fine in XCode 11 on Catalina on an old Intel MBP. I've recently purchased an M3 Max machine and want to bring this app forward.

Just going from XCode 11 to XCode 12 on the old machine, not even trying yet to up to XCode 14 or 15 on the new machine, I get two build errors that I have no idea how to resolve, both in bnns.h. I have not deliberately included this framework, and text search in my project and dependencies finds no incidence of "bnns" at all.

These occur in the function prototypes for BNNSApplyMultiheadAttention and BNNSApplyMultiheadAttentionBackward. These prototypes look okay to me, and again I didn't deliberately invoke them in the first place.

Does anybody have any idea how I can get past this roadblock?

p.s. this is what the first prototype looks like; no unbalanced parens here (spacing edited for readability):

int BNNSApplyMultiheadAttention(BNNSFilter F, size_t batch_size,
    void const* query, size_t query_stride,
    void const* key, size_t key_stride,
    BNNSNDArrayDescriptor const* _Nullable key_mask, size_t key_mask_stride,
     void const* value, size_t value_stride,
     void *output, size_t output_stride,
     BNNSNDArrayDescriptor const* _Nullable add_to_attention,
      size_t * _Nullable backprop_cache_size, void * _Nullable backprop_cache,
       size_t * _Nullable workspace_size, void * _Nullable workspace)
Answered by DTS Engineer in 841308022

Yet again I find myself agreeing with Etresoft (-:

For context, I tried this here in my office and I didn’t have a problem. Specifically:

  1. Using Xcode 16.4 on macOS 15.4, I created a new project from the macOS > Command Line Tool template, choosing C as the language.

  2. I replaced main.c with the code shown below.

  3. The project built just fine.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


#include <stdio.h>
#include <Accelerate/Accelerate.h>

int BNNSApplyMultiheadAttention(BNNSFilter F, size_t batch_size,
    void const* query, size_t query_stride,
    void const* key, size_t key_stride,
    BNNSNDArrayDescriptor const* _Nullable key_mask, size_t key_mask_stride,
     void const* value, size_t value_stride,
     void *output, size_t output_stride,
     BNNSNDArrayDescriptor const* _Nullable add_to_attention,
      size_t * _Nullable backprop_cache_size, void * _Nullable backprop_cache,
       size_t * _Nullable workspace_size, void * _Nullable workspace)
{
    abort();
}

int main(int argc, const char * argv[]) {
    // insert code here...
    printf("Hello, World!\n");
    return 0;
}

That's part of the accelerate framework. You have probably defined some macro that taking effect before the header is included.

Yet again I find myself agreeing with Etresoft (-:

For context, I tried this here in my office and I didn’t have a problem. Specifically:

  1. Using Xcode 16.4 on macOS 15.4, I created a new project from the macOS > Command Line Tool template, choosing C as the language.

  2. I replaced main.c with the code shown below.

  3. The project built just fine.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


#include <stdio.h>
#include <Accelerate/Accelerate.h>

int BNNSApplyMultiheadAttention(BNNSFilter F, size_t batch_size,
    void const* query, size_t query_stride,
    void const* key, size_t key_stride,
    BNNSNDArrayDescriptor const* _Nullable key_mask, size_t key_mask_stride,
     void const* value, size_t value_stride,
     void *output, size_t output_stride,
     BNNSNDArrayDescriptor const* _Nullable add_to_attention,
      size_t * _Nullable backprop_cache_size, void * _Nullable backprop_cache,
       size_t * _Nullable workspace_size, void * _Nullable workspace)
{
    abort();
}

int main(int argc, const char * argv[]) {
    // insert code here...
    printf("Hello, World!\n");
    return 0;
}

Huh. Well, thanks; that gave me the clue I needed to get past that point, though i'm still puzzled.

In the one place where I use the Accelerate framework, even if I #import (or #include) <Accelerate/Accelerate.h> in the very first line of the header, which is #included in its .C file before anything else is defined or called, I still get the exact same build error! But, I realized that the only thing needed out of there is vDSP.h (for Fast Fourier transforms), so that's all I have there now, and it builds.

(The next problem will be getting my OpenCL kernel built — I know that's been deprecated, but it's still in the SDK. I get the GPU returned as a valid OpenCL device and I can do clCreateProgramWithSource(), but when I try to clBuildProgram() on that, I get Device Not Available. FWIW, opencl in general seems to be messed up specifically in Sonoma 14.4, which is what I have, and I dunno if going to Sequoia would help at all. A problem for another post if I can't solve it on my own.)

UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed [CL_DEVICE_NOT_AVAILABLE] : OpenCL Error : Error: Build Program driver returned (10014)

Anyway, thanks very much!!!

[I haven't yet decided which of these answers I should Accept; I'm new here....]

Error in bnns.h - Missing ')'
 
 
Q