On 17 March 2014 08:06, Walter Bright <newshou...@digitalmars.com> wrote: > On 3/17/2014 12:39 AM, Iain Buclaw wrote: >> >> If I recall, he was saying that you must pass >> -fversion=CAIRO_HAS_PNG_SUPPORT to >> every file that imports it was the problem, because you want PNG support, >> not stubs. > > > Stub out the functions for PNG support. Then just call them, they will do > nothing if PNG isn't supported. There is NO NEED for the callers to set > version. > > > >> It's more an example where you need a build system in place for a simple >> hello >> world in cairoD if you don't want to be typing too much just to get your >> test >> program built. :) > > > If you need to -fversion=CAIRO_HAS_PNG_SUPPORT for every file that imports > it, you have completely misunderstood the design I suggested. > > 1. Encapsulate the feature in a function. > > 2. Implement the function in module X. Module X is the ONLY module that > needs the version. In module X, define the function to do nothing if version > is false. > > 3. Nobody who imports X has to define the version. > > 4. Just call the function as if the feature always exists. > > 5. If you find you still need a version in the importer, then you didn't > fully encapsulate the feature. Go back to step 1.
Right, but going back full circle to the original comment: "For example cairoD wraps the cairo C library. cairo can be compiled without or with PNG support. Historically cairoD used version(CAIRO_HAS_PNG_SUPPORT) for this." Requires that cairoD have this encapsulation you suggest, but also requires detection in some form of configure system that checks: 1) Is cairo installed? (Mandatory, fails without) 2) Does the installed version of cairo have PNG suport (If true, set build to compile a version of module X with version=CAIRO_HAS_PNG_SUPPORT)