Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8125561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:51:43+00:00 2026-06-06T06:51:43+00:00

I’m developing a small OOP/RAII library that wraps Win32’s mixerXXX API functions. I’m writing

  • 0

I’m developing a small OOP/RAII library that wraps Win32’s mixerXXX API functions.

I’m writing a class that encapsulates the MIXERLINE structure, so my MixerLine class has this as its header:

#pragma once
#define UNICODE
#include <stdio.h>
#include <string>
#include <windows.h>
#include "MixerDevice.h"

//////////////////////////////

class MixerLine {

private:
    MIXERLINE _mixerLine;

public:

    MixerLine(MixerDevice& parentMixer, DWORD destinationIndex); 

    ~MixerLine();

};

However I get a syntax error (in VC9):

Error 2 error C2061: syntax error : identifier ‘MixerDevice’ d:\tfs\misc\winwavein\mixerline.h

Why isn’t the message more helpful? I have no idea what’s wrong with it.

FWIW, there are no errors at all in the file MixerDevice.h.

EDIT: Here are the original, entire files:

MixerLine.h

#pragma once

#define UNICODE
#include <stdio.h>
#include <string>

#include <windows.h>

#include "MixerDevice.h"

//////////////////////////////

class MixerLine {

private:
    MIXERLINE _mixerLine;

public:

    MixerLine(MixerDevice& parentMixer, DWORD destinationIndex); 

    ~MixerLine();

    // Properties

    DWORD getDestinationLineIndex() {
        return _mixerLine.dwDestination;
    }   

    DWORD getSourceIndex() {
        return _mixerLine.dwSource;
    }

    DWORD getLineId() {
        return _mixerLine.dwLineID;
    }

    DWORD getStatus() {
        return _mixerLine.fdwLine;
    }

    std:wstring getStatusString() {

        switch( _mixerLine.fdwLine ) {
            case MIXERLINE_LINEF_ACTIVE:
                return L"MIXERLINE_LINEF_ACTIVE";
            case MIXERLINE_LINEF_DISCONNECTED:
                return L"MIXERLINE_LINEF_DISCONNECTED";
            case MIXERLINE_LINEF_SOURCE:
                return L"MIXERLINE_LINEF_SOURCE";
            default:
                return L"";
        }

    }

    DWORD getUserData() {
        return _mixerLine.dwUser;
    }

    DWORD getComponentType() {
        return _mixerLine.dwComponentType;
    }
};

MixerDevice.h

#pragma once
#define UNICODE

#include <memory>
#include <stdio.h>
#include <iostream>
#include <vector>

#include <windows.h>

////////////////////////

#include "MixerLine.h"

class MixerDevice {

    private:
        DWORD     _deviceId;
        HMIXER    _mixerHandle;
        MIXERCAPS _mixerCaps;

    public:
        MixerDevice(DWORD deviceId);
        ~MixerDevice();

        void enumerateLines();

        // Properties

        DWORD getDeviceId() {
            return _deviceId;
        }

        HMIXEROBJ getHandle() {
            return (HMIXEROBJ)_mixerHandle;
        }

        // Caps

        WORD getManufacturerId() {
            return _mixerCaps.wMid;
        }
        WORD getProductId() {
            return _mixerCaps.wPid;
        }
        MMVERSION getDriverVersion() {
            return _mixerCaps.vDriverVersion;
        }
        WCHAR* getProductName() {
            return _mixerCaps.szPname;
        }
        DWORD getSupportBits() {
            return _mixerCaps.fdwSupport;
        }
        DWORD getDestinationCount() {
            return _mixerCaps.cDestinations;
        }
    };

MixerDevice.cpp (the file I’m trying to compile):

#include "MixerDevice.h"

using namespace std;

MixerDevice::MixerDevice(DWORD deviceId) {

    _deviceId = deviceId;

    MMRESULT result;

    result = mixerOpen( &_mixerHandle, deviceId, NULL, NULL, MIXER_OBJECTF_MIXER );
    if( result != MMSYSERR_NOERROR ) throw new exception("Call to mixerOpen failed.", result);

    result = mixerGetDevCaps( (UINT)_mixerHandle, &_mixerCaps, sizeof(MIXERCAPS) );
    if( result != MMSYSERR_NOERROR ) throw new exception("Call to mixerGetDevCaps failed.", result);
}

MixerDevice::~MixerDevice() {

    MMRESULT result = mixerClose( _mixerHandle );
    if( result != MMSYSERR_NOERROR ) exit(666);
}

// Methods

void MixerDevice::enumerateLines() {    
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:51:45+00:00Added an answer on June 6, 2026 at 6:51 am

    As Luchian Grigore already stated, a forward-declaration is better if it’s sufficient than including the whole header (at least, here, and IMHO).

    #pragma once does not help with circular inclusions, it only avoids infinite inclusions._

    But the inclusion starts within MixerDevice.cpp:

    MixerDevice.cpp —#include–> MixerDevice.h —#include–> MixerLine.h —#include–>MixerDevice.h

    That last #include directive does nothing because of the #pragma once in MixerDevice.h. The preprocessor assembles a single document (translation unit) that looks like (use /P or /showIncludes to see that):

    1. contents of several StdLib and windows headers
    2. contents of MixerLine.h
    3. contents of MixerDevice.h
    4. contents of MixerDevice.cpp

    This is what the compiler receives as input, effectively. Now, when the compiler reaches the line within the contents of MixerLine.h:

    MixerLine(MixerDevice& parentMixer, DWORD destinationIndex);
    

    The name MixerDevice is not known yet; that name is introduced “below” in the document within the contents of MixerDevice.h. You need at least declare the class MixerDevice before using its name. You could also change your inclusion order as MixerDevice currently does not depend on MixerLine, but you’ll probably run into more trouble later this way.

    After some discussion with Luchian Grigore I want to point out:

    Don’t solve the problem by reversing the inclusion order, this solution is something that works ONLY in this particular case and ONLY if you mention no name in MixerDevice.h that is only declared in MixerLine.h. Use forward-declarations instead, as mentioned by Luchian Grigore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
I am writing an app with both english and french support. The app requests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.