gpt4 book ai didi

c++ - C++-头文件中的接口(interface)

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:09:08 25 4
gpt4 key购买 nike

我应该编写一个与 uEye 相机交互的 C++ 程序。为此,我必须包含几个文件,其中一个是头文件,其中包含大约 30 个接口(interface),如下所示。当我运行包含此头文件的 C++ 程序时,出现错误:

“错误:预期标识符或‘(’在‘:’标记之前”

在头文件中每个接口(interface)的第一行(interface IuEyeAutoFeatures : public IUnknown)。

这是头文件中的接口(interface)之一:

interface IuEyeAutoFeatures : public IUnknown
{
STDMETHOD(SetAutoBrightnessReference)(long lReference) = 0;
STDMETHOD(GetAutoBrightnessReference)(long* plReference) = 0;
STDMETHOD(SetAutoBrightnessMaxExposure)(long lMaxExposure) = 0;
STDMETHOD(GetAutoBrightnessMaxExposure)(long* plMaxExposure) = 0;
STDMETHOD(SetAutoBrightnessMaxGain)(long lMaxGain) = 0;
STDMETHOD(GetAutoBrightnessMaxGain)(long* plMaxGain) = 0;
STDMETHOD(SetAutoBrightnessSpeed)(long lSpeed) = 0;
STDMETHOD(GetAutoBrightnessSpeed)(long* plSpeed) = 0;
STDMETHOD(SetAutoBrightnessAOI)(long lXPos, long lYPos, long lWidth, long lHeight) = 0;
STDMETHOD(GetAutoBrightnessAOI)(long* plXPos, long* plYPos, long* plWidth, long* plHeight) = 0;
STDMETHOD(SetAutoWBGainOffsets)(long lRedOffset, long lBlueOffset) = 0;
STDMETHOD(GetAutoWBGainOffsets)(long* plRedOffset, long* plBlueOffset) = 0;
STDMETHOD(SetAutoWBGainRange)(long lMinRGBGain, long lMaxRGBGain) = 0;
STDMETHOD(GetAutoWBGainRange)(long* plMinRGBGain, long* plMaxRGBGain) = 0;
STDMETHOD(SetAutoWBSpeed)(long lSpeed) = 0;
STDMETHOD(GetAutoWBSpeed)(long* plSpeed) = 0;
STDMETHOD(SetAutoWBAOI)(long lXPos, long lYPos, long lWidth, long lHeight) = 0;
STDMETHOD(GetAutoWBAOI)(long* plXPos, long* plYPos, long* plWidth, long* plHeight) = 0;
};
DEFINE_GUID(IID_IuEyeFaceDetection,
0xe122a994, 0xfc4d, 0x445b, 0xb2, 0x1c, 0x30, 0x8b, 0x67, 0x48, 0x44, 0xe0);

#ifndef DS_EXPORT
# define DS_EXPORT
# ifdef _UEYETIME
# undef _UEYETIME
# endif
# ifdef UEYETIME
# undef UEYETIME
# endif
typedef struct _UEYETIME
{
WORD wYear;
WORD wMonth;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
BYTE byReserved[10];
} UEYETIME;
#endif /* DS_EXPORT */

#ifndef DS_EXPORT
# define DS_EXPORT
# ifdef S_FDT_INFO_EL
# undef S_FDT_INFO_EL
# endif
# ifdef FDT_INFO_EL
# undef FDT_INFO_EL
# endif
/*!
* \brief uEye face detection info element data type.
* Info on a single detected face as listed by \see FDT_INFO_LIST.
*/
typedef struct S_FDT_INFO_EL
{
INT nFacePosX; /*!< \brief Start X position. */
INT nFacePosY; /*!< \brief Start Y position. */
INT nFaceWidth; /*!< \brief Face width. */
INT nFaceHeight; /*!< \brief Face height. */
INT nAngle; /*!< \brief Face Angle (0...360° clockwise, 0° at twelve o'clock position. -1: undefined ). */
UINT nPosture; /*!< \brief Face posture. */
UEYETIME TimestampSystem; /*!< \brief System time stamp (device query time) . */
UINT64 nReserved; /*!< \brief Reserved for future use. */
UINT nReserved2[4]; /*!< \brief Reserved for future use. */
} FDT_INFO_EL;
#endif /* DS_EXPORT */

#ifndef DS_EXPORT
# define DS_EXPORT
# ifdef S_FDT_INFO_LIST
# undef S_FDT_INFO_LIST
# endif
# ifdef FDT_INFO_LIST
# undef FDT_INFO_LIST
# endif
/*!
* \brief uEye face detection info list data type.
* List of detected faces, lists \see FDT_INFO_EL objects.
*/
typedef struct S_FDT_INFO_LIST
{
UINT nSizeOfListEntry; /*!< \brief Size of one list entry in byte(in). */
UINT nNumDetectedFaces; /*!< \brief Number of detected faces(out). */
UINT nNumListElements; /*!< \brief Number of list elements(in). */
UINT nReserved[4]; /*!< \brief reserved for future use(out). */
FDT_INFO_EL FaceEntry[1]; /*!< \brief First face entry. */
} FDT_INFO_LIST;
#endif /* DS_EXPORT */

据我所知,使用“接口(interface)”一词声明接口(interface)是在Java 等语言中完成的,而不是在c++ 中完成的,所以我不明白为什么这个头文件会这样声明接口(interface)。由于这个头文件是由公司 IDS 在下载他们的驱动程序后提供的,我想它应该是正确的。

如何修复该错误并使我的程序正常运行?

提前致谢

最佳答案

interface是预处理器宏,通常与 COM 接口(interface)一起使用。它在 combaseapi.h 中定义为:

#define __STRUCT__ struct
#define interface __STRUCT__

在包含接口(interface) header 之前,您需要包含该头文件(直接或间接通过 #include <objbase.h> )。

关于c++ - C++-头文件中的接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44604920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com