I was trying to compile stk. During the configuration I get the error
System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:162:2: error: expected identifier or '(' before '^' token (^AudioObjectPropertyListenerBlock)(
When I see the code I see ^
inside the function pointer declaration at line 162 in here. I know we can have *
but what does ^
mean?
Code snippet :
#if defined(__BLOCKS__)
typedef void
(^AudioObjectPropertyListenerBlock)( UInt32 inNumberAddresses,
const AudioObjectPropertyAddress inAddresses[]);
As other answerers here say, it could be in C++/CLI.
But also, if you are on a macOS (like you hinted in one comment), this is an Objective-C block.
Its syntax is very very weird.
The block is like a C++ closures and Java anonymous inner classes, it can capture variables.
__block int insider = 0;
void(^block)() = ^{
// print insider here using your favourite method, printf for example
};
This is a complete NSObject
(base Objective-C class), but is callable, this is not a mere function pointer.
Refer to this Apple document: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
Now, we go to the important question, I want to run this on Linux, how ???
LLVM supports block syntax, but you should refer to this StackOverflow question for more: Clang block in Linux?
So, you should compile your code in the LLVM compiler, and use -fblocks and -lBlocksRuntime.
Don't forget to install those Linux packages:
llvm clang libblocksruntime-dev
If you are already on macOS, just use -fblocks.