Почему `IAudioMeterInformation` - неполный тип? - PullRequest
1 голос
/ 26 мая 2020

Попытка скомпилировать следующее с помощью g++ main.cpp -lwinmm вызывает следующие ошибки:

main.cpp: In function 'int main()':
main.cpp:15:15: error: invalid use of incomplete type 'IAudioMeterInformation' {aka 'struct IAudioMeterInformation'}
     pMeterInfo->GetPeakValue(&audiolevel);
               ^~
In file included from main.cpp:3:
C:/Mingw-w64/mingw64/x86_64-w64-mingw32/include/endpointvolume.h:90:19: note: forward declaration of 'IAudioMeterInformation' {aka 'struct IAudioMeterInformation'}
 typedef interface IAudioMeterInformation IAudioMeterInformation;
                   ^~~~~~~~~~~~~~~~~~~~~~
main.cpp:18:19: error: invalid use of incomplete type 'IAudioMeterInformation' {aka 'struct IAudioMeterInformation'}
         pMeterInfo->GetPeakValue(&audiolevel);
                   ^~
In file included from main.cpp:3:
C:/Mingw-w64/mingw64/x86_64-w64-mingw32/include/endpointvolume.h:90:19: note: forward declaration of 'IAudioMeterInformation' {aka 'struct IAudioMeterInformation'}
 typedef interface IAudioMeterInformation IAudioMeterInformation;
#include <windows.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#include <iostream>

int main() {
    float audiolevel = 0.0;
    IMMDeviceEnumerator* pEnumerator = NULL;
    IMMDevice* pDevice = NULL;
    IAudioMeterInformation* pMeterInfo = NULL;
    CoInitialize(NULL);
    CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator);
    pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice);
    pDevice->Activate(__uuidof(IAudioMeterInformation), CLSCTX_ALL, NULL, (void**)&pMeterInfo);
    pMeterInfo->GetPeakValue(&audiolevel);
    while (1) {
        std::cout << audiolevel << std::endl;
        pMeterInfo->GetPeakValue(&audiolevel);
    }
}

Почему?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...