Common (Windows): allows COM be used in C sources

This commit is contained in:
李通洲
2026-05-06 15:01:40 +08:00
parent dca3b154ef
commit 8159f473cc
6 changed files with 15 additions and 16 deletions
@@ -1,4 +1,4 @@
#include "com.hpp"
#include "com.h"
#include <roapi.h>
@@ -1,23 +1,23 @@
#pragma once
#ifdef __cplusplus
#include "common/attributes.h"
#include <unknwn.h>
#include "common/attributes.h"
#include <assert.h>
#include <unknwn.h>
// Initialize COM & WinRT
const char* ffInitCom(void);
static inline void ffReleaseComObject(void* ppUnknown) {
assert(ppUnknown);
IUnknown* pUnknown = *(IUnknown**) ppUnknown;
if (pUnknown) {
#ifdef __cplusplus
pUnknown->Release();
#else
pUnknown->lpVtbl->Release(pUnknown);
#endif
*(IUnknown**) ppUnknown = NULL;
}
}
#define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)
#else
// Win32 COM headers requires C++ compiler
#error Must be included in C++ source file
#endif
#define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)