0

I'm trying to assign a function to the AURenderCallback inputProc

int setupRemoteIO(audio unit etc){
    inProc.inputProc = playerCallback
}     

but it says that playerCallback is not declared in this scope although playerCallback is present in the same file and class as setupRemoteIO.

The player callback is like this

static OSStatus playerCallback(void *inRefCon etc)

What could be the problem?

3
  • 4
    Is playerCallback() declared before setupRemoteIO() in the file? Commented May 28, 2012 at 7:18
  • 2
    It might be a good idea to put the c-functions prototypes at the header or visible class extension. Commented May 28, 2012 at 7:39
  • @Graham: It wasn't. Thanks so much!! Commented May 28, 2012 at 7:50

1 Answer 1

2

In C, you need to declare a function before its first use, i.e. higher up in the file than the point where you try to use the function. That's why include files are usually clustered at the top of a file; all of the symbols declared in the headers will be available throughout the code in the including file.

In this case, that means the declaration of your callback:

static OSStatus playerCallback(void *inRefCon etc);

must appear before your setupRemoteIO() function so that the compiler knows the function exists when you come to use it.

As you're on iOS, I'll also make the point that in recent compilers this restriction doesn't apply to Objective-C methods. It used to: you could only use method selectors that had already been seen. But in newer versions of Clang an Objective-C method can make use of a selector declared later in the same file without error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.