smjg
Joined: 29 Sep 2004 Posts: 41
|
Posted: Fri Oct 17, 2008 4:06 pm Post subject: WindowsAPI style: extern (Windows) and COM interfaces |
|
|
We seem to have a handful of different styles for the extern (Windows) (or lack thereof) applied to COM interfaces.
1. Not at all - most instances at the moment
2. extern (Windows) wrapping the whole interface - unknwn.d
Code: | extern (Windows) {
interface IUnknown {
HRESULT QueryInterface(IID* riid, void** pvObject);
ULONG AddRef();
ULONG Release();
}
// ...
}
|
3. with a colon just inside the interface - directx modules
Code: | interface ID3D10DeviceChild : IUnknown {
extern(Windows) :
void GetDevice(ID3D10Device* ppDevice);
HRESULT GetPrivateData(REFGUID guid, UINT *pDataSize, void *pData);
HRESULT SetPrivateData(REFGUID guid, UINT DataSize, void *pData);
HRESULT SetPrivateDataInterface(REFGUID guid, IUnknown pData);
}
|
We should decide on a consistent style to use. And while I'm not sure I like the indentation of style 3, if we're going to use this one we ought to change the spacing to extern (Windows): to be consistent with other things.
Other possibilities:
4. Code: | extern (Windows) interface IUnknown {
HRESULT QueryInterface(IID* riid, void** pvObject);
ULONG AddRef();
ULONG Release();
}
|
5. Code: | interface IUnknown {
extern (Windows) {
HRESULT QueryInterface(IID* riid, void** pvObject);
ULONG AddRef();
ULONG Release();
}
}
|
6. Code: | interface IUnknown {
extern (Windows):
HRESULT QueryInterface(IID* riid, void** pvObject);
ULONG AddRef();
ULONG Release();
}
|
7. Code: | interface IUnknown {
extern (Windows):
HRESULT QueryInterface(IID* riid, void** pvObject);
ULONG AddRef();
ULONG Release();
}
|
First, somebody who knows how to test it needs to confirm: Is the extern (Windows) necessary? If so, do styles 2 and 3 both achieve the intended result?
Assuming that it works, my vote would go to style 2, enabling a single extern (Windows) to wrap multiple COM interfaces (and possibly global functions as well). Style 4 would be used when there is just the one interface to declare as extern (Windows).
What does everyone think?
Stewart. |
|