On 2014-03-17 01:20:37 +0000, Walter Bright <newshou...@digitalmars.com> said:
On 3/15/2014 6:44 AM, Johannes Pfau wrote:
Then in cairo.d
version(CAIRO_HAS_PNG_SUPPORT)
{
extern(C) int cairo_save_png(char* x);
void savePNG(string x){cairo_save_png(toStringz(x))};
}
try adding:
else
{
void savePNG(string x) { }
}
and then your users can just call savePNG without checking the version.
Adding a stub that does nothing, not even a runtime error, isn't a very
good solution in my book. If this function call should fail, it should
fail early and noisily.
So here's my suggestion: use a template function for the wrapper.
extern(C) int cairo_save_png(char* x);
void savePNG()(string x){cairo_save_png(toStringz(x));}
If you call it somewhere it and cairo_save_png was not compiled in
Cairo, you'll get a link-time error (undefined symbol cairo_save_png).
If you don't call savePNG anyhere there's no issue because savePNG was
never instantiated.
--
Michel Fortin
michel.for...@michelf.ca
http://michelf.ca