getNamedResource cpp prototype


#1

I’m not sure how new this is but I’ve just noticed that BinaryData::getNamedResource now only appears in BinaryData.cpp. Shouldn’t the function prototype be in the header file? It looks like this at the moment:

const char* getNamedResource (const char*, int&) throw(); const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw() { ... }


#2

Yeah, that’s deliberate. There was some kind of stupid compiler warning that was triggered unless the function had a prototype, and since BinaryData.cpp doesn’t actually include BinaryData.h, I just duplicated it in there.


#3

I just wanted to add that maybe a macro for fetching images would be nice, i use that a lot

#define img(x)												ImageCache::getFromMemory(x, x ## Size)

#4

Nice idea. (It’s good practice to always make your macros upper-case though!)


#5

Ok that makes sense but its only present in the cpp file, the header needs the prototype as well other wise its not visible to the rest of the project.


#6

I’m confused… AFAICT it’s in the header as well, right?


#7

Not for me at least. Pulled the tip this morning (“AU plugin hosting: now…”), generate new Introjucer project, add an ogg file to it, this is the full contents of the header:

[code]/* =========================================================================================

This is an auto-generated file, created by The Introjucer 3.0.0
Do not edit anything in this file!

*/

namespace BinaryData
{
extern const char* Whitenoisesound_ogg;
const int Whitenoisesound_oggSize = 660867;

}[/code]


#8

Oh, I see… I’ve mistakenly made it omit that if there aren’t any images in your resources. All my projects do contain images so I hadn’t noticed. I’ll sort that out now…


#9

Sorted, thanks.