Sane API design (AKA C's #ifdef hell)

Kagamin spam at here.lot
Mon Apr 20 17:57:03 UTC 2026


On Friday, 17 April 2026 at 14:37:28 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
> Metadata generators can be quite good like with OpenGL, but 
> there are others... such as COM which are absolutely horrid c++ 
> mixed monstrosities. I'm still unsure if it was a good thing or 
> not for Walter to never implement it. It was part of D's 
> original design document to include support.

Did I miss something? D supports COM, I wrote bindings for 7zip 
COM interfaces and it's as clean as you can get
```d
interface IArchiveOpenCallback : IUnknown
{
	enum ID=ArchiveIID(0x10);
	HRESULT SetTotal(in ulong* files, in ulong* bytes);
	HRESULT SetCompleted(in ulong* files, in ulong* bytes);
}

interface IProgress : IUnknown
{
	enum ID=CommonIID(0, 5);
	HRESULT SetTotal(in ulong total);
	HRESULT SetCompleted(in ulong* completeValue);
}

interface IArchiveExtractCallback : IProgress
{
	enum ID=ArchiveIID(0x20);
	HRESULT GetStream(uint index, ISequentialOutStream* outStream, 
int askExtractMode);
	HRESULT PrepareOperation(int askExtractMode);
	HRESULT SetOperationResult(int opRes);
}
```
granted, 7zip doesn't use ifdef hell.


More information about the Digitalmars-d mailing list