When building I get a warning like this:
`MyReadProc' declared `static' but never defined
Can someone please help me with this?
When building I get a warning like this:
`MyReadProc' declared `static' but never defined
Can someone please help me with this?
You cantīt teach an old dog new tricks.
Without seeing the code, it's very difficult to say what's wrong. Even so, here's a guess:
You have declared a function MyReadProc but not defined it...
In other words, you have something like this:
somewhere, without ever defining the function MyReadProc.Code:static void MyReadProc();
The reason why you don't get this for normal non-static functions is because static functions are only accessible from within the execution unit (think file...) in which they are defined/declared. Non-static functions can be declared but not defined and the linker tries to resolve it later. Static functions can only be used in the same execution unit in which they were defined/declared and so the linker won't try and resolve them later... hence the warning.
If you've done something like declared MyReadProc as static in a header file and then included that header file, then you'll get the kind of error. Declaring it static means that you cannot link to it outside of the execution unit in which it was defined, so it cannot be called by anyone outside of the file. Adding it to a header file is erroneous. If you do want to be able to call it from other execution units, then you need to make it a non-static function.
Static is one of those things in C which means different things in different contexts. A static variable is something completely different to a static function.
I hope that explains your warning...!
Ian Woods
I will tell you what I am trying to do.Originally posted by hairyian
Without seeing the code, it's very difficult to say what's wrong. Even so, here's a guess:
You have declared a function MyReadProc but not defined it...
In other words, you have something like this:
somewhere, without ever defining the function MyReadProc.Code:static void MyReadProc();
The reason why you don't get this for normal non-static functions is because static functions are only accessible from within the execution unit (think file...) in which they are defined/declared. Non-static functions can be declared but not defined and the linker tries to resolve it later. Static functions can only be used in the same execution unit in which they were defined/declared and so the linker won't try and resolve them later... hence the warning.
If you've done something like declared MyReadProc as static in a header file and then included that header file, then you'll get the kind of error. Declaring it static means that you cannot link to it outside of the execution unit in which it was defined, so it cannot be called by anyone outside of the file. Adding it to a header file is erroneous. If you do want to be able to call it from other execution units, then you need to make it a non-static function.
Static is one of those things in C which means different things in different contexts. A static variable is something completely different to a static function.
I hope that explains your warning...!
Ian Woods
I have a file called midithruCategory.m where the static function is located like this:
static void MyReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon)
{
some code...
}
I also have a file called initvintageeightCategory.m that looks like this:
// Create client and port
MIDIClientRef client = NULL;
MIDIClientCreate(CFSTR("VintageEight"), NULL, NULL, &client);
MIDIPortRef inPort = NULL;
MIDIInputPortCreate(client, CFSTR("Input port"), MyReadProc, NULL, &inPort);
MIDIOutputPortCreate(client, CFSTR("Output port"), &gOutPort);
The thing I want to do here is now a lot clearer and maybe you can tell me what I must do to make this work?
I also have .h files with the same names as the .m files
You cantīt teach an old dog new tricks.
Hold your horses, I think I got it now :-)Originally posted by electrolove
I will tell you what I am trying to do.
I have a file called midithruCategory.m where the static function is located like this:
static void MyReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon)
{
some code...
}
I also have a file called initvintageeightCategory.m that looks like this:
// Create client and port
MIDIClientRef client = NULL;
MIDIClientCreate(CFSTR("VintageEight"), NULL, NULL, &client);
MIDIPortRef inPort = NULL;
MIDIInputPortCreate(client, CFSTR("Input port"), MyReadProc, NULL, &inPort);
MIDIOutputPortCreate(client, CFSTR("Output port"), &gOutPort);
The thing I want to do here is now a lot clearer and maybe you can tell me what I must do to make this work?
I also have .h files with the same names as the .m files
You cantīt teach an old dog new tricks.