簡體   English   中英

C / C混淆

[英]c++ / c confusion

我正在嘗試用c ++制作一個小型應用程序,以使用該庫節省內存。 http://musicnote.sourceforge.net/docs/html/index.html

主頁上提供的示例代碼如下所示。

 #include "MusicNoteLib.h"
    void main()
    {
        MusicNoteLib::Player player; // Create the Player Object
        player.Play("C D E F G A B"); // Play the Music Notes on the default MIDI output port
    }

這段代碼無法在Visual Studio 2008中編譯,我遇到很多錯誤,例如

MusicNoteLib.h(22):錯誤C4430:缺少類型說明符-假定為int。 注意:C ++不支持default-int

我不明白該錯誤或從哪里開始尋找...還有一些dll文件可以代替該h文件使用。

    #ifndef __MUSICNOTE_LIB_H__EBEE094C_FF6E_43a1_A6CE_D619564F9C6A__
#define __MUSICNOTE_LIB_H__EBEE094C_FF6E_43a1_A6CE_D619564F9C6A__

/** @file MusicNoteLib.h
 * \brief Main header file for accessing the MusicNote Library
 */ 

/// <Summary>
/// This header file can be included directly in your project or through
/// MusicNoteLib.h of the MusicNoteDll project. If included directly, this
/// will be built directly as a satic library. If included through MusicNoteDll
/// this will use dllImports through MUSICNOTELIB_API
/// </Summary>
#ifndef MUSICNOTELIB_API
#define MUSICNOTELIB_API
#endif // MUSICNOTELIB_API

//#include "Player.h"

namespace MusicNoteLib /// Music Programming Library
{
typedef  void (__stdcall *LPFNTRACEPROC)(void* pUserData, const TCHAR* szTraceMsg);
typedef  void (__stdcall *LPFNERRORPROC)(void* pUserData, long lErrCode, const TCHAR* szErrorMsg, const TCHAR* szToken);

extern "C"
{
    MUSICNOTELIB_API typedef void MStringPlayer;

    MUSICNOTELIB_API void* GetCarnaticMusicNoteReader();

    /// <Summary>
    /// Creates a MusicString Player object.
    /// </Summary>
    MUSICNOTELIB_API MStringPlayer* CreateMusicStringPlayer();

    /// <Summary>
    /// Plays Music string notes on the default MIDI Output device with the default Timer Resolution.
    /// Use PlayMusicStringWithOpts() to use custom values.
    /// @param szMusicNotes the Music string to be played on the MIDI output device
    /// @return True if the notes were played successfully, False otherwise
    /// </Summary>
    MUSICNOTELIB_API bool PlayMusicString(const TCHAR* szMusicNotes);

    /// <Summary>
    /// Same as PlayMusicString() except that this method accepts Callbacks.
    /// The Trace and Error callbacks will be used during the Parse of the Music Notes.
    /// @param szMusicNotes the Music string to be played on the MIDI output device
    /// @param traceCallbackProc the Callback to used to report Trace messages
    /// @param errorCallbackProc the Callback to used to report Error messages
    /// @param pUserData any user supplied data that should be sent to the Callback
    /// @return True if the notes were played successfully, False otherwise
    /// </Summary>
    MUSICNOTELIB_API bool PlayMusicStringCB(const TCHAR* szMusicNotes,
                                            LPFNTRACEPROC traceCallbackProc, 
                                            LPFNERRORPROC errorCallbackProc, 
                                            void* pUserData);

    /// <Summary>
    /// Plays Music string notes on the given MIDI Output device using the given Timer Resolution.
    /// Use PlayMusicString() to use default values.
    /// @param szMusicNotes the Music notes to be played
    /// @param nMidiOutPortID the device ID of the MIDI output port to be used for the play
    /// @param nTimerResMS preferred MIDI timer resolution, in MilliSeconds
    /// @return True if Play was successful, False otherwise
    /// </Summary>
    MUSICNOTELIB_API bool PlayMusicStringWithOpts(const TCHAR* szMusicNotes, int nMidiOutPortID, unsigned int nTimerResMS);

    /// <Summary>
    /// Same as PlayMusicStringWithOpts() except that this method accepts Callbacks.
    /// The Trace and Error callbacks will be used during the Parse of the Music Notes.
    /// @param szMusicNotes the Music notes to be played
    /// @param nMidiOutPortID the device ID of the MIDI output port to be used for the play
    /// @param nTimerResMS preferred MIDI timer resolution, in MilliSeconds
    /// @param traceCallbackProc the Callback to used to report Trace messages
    /// @param errorCallbackProc the Callback to used to report Error messages
    /// @param pUserData any user supplied data that should be sent to the Callback
    /// @return True if Play was successful, False otherwise
    /// </Summary>
    MUSICNOTELIB_API bool PlayMusicStringWithOptsCB(const TCHAR* szMusicNotes, 
                                                    int nMidiOutPortID, 
                                                    unsigned int nTimerResMS,
                                                    LPFNTRACEPROC traceCallbackProc, 
                                                    LPFNERRORPROC errorCallbackProc, 
                                                    void* pUserData);
    /// <Summary>
    /// Save the given MusicString content into a MIDI output file
    /// @param szMusicNotes Music Notes to be converted to MIDI output
    /// @param szOutputFilePath path of the MIDI output file
    /// @return True if the the content was saved successfully, False otherwise
    /// </Summary>
    MUSICNOTELIB_API bool SaveAsMidiFile(const TCHAR* szMusicNotes, const char* szOutputFilePath);

    //MUSICNOTELIB_API typedef void (*ParseErrorProc)(const MusicNoteLib::CParser*, MusicNoteLib::CParser::ErrorEventHandlerArgs* pEvArgs);
    //MUSICNOTELIB_API typedef void (*ParseTraceProc)(const MusicNoteLib::CParser*, MusicNoteLib::CParser::TraceEventHandlerArgs* pEvArgs);

    MUSICNOTELIB_API void Parse(const TCHAR* szNotes, LPFNTRACEPROC traceCallbackProc, void* pUserData);

} // extern "C"



} // namespace MusicNoteLib

#endif // __MUSICNOTE_LIB_H__EBEE094C_FF6E_43a1_A6CE_D619564F9C6A__

錯誤在此行上:

typedef  void (__stdcall *LPFNTRACEPROC)(void* pUserData, const TCHAR* szTraceMsg);

自從我“憤怒”地執行C / C ++以來已經有一段時間了,所以我在這里有些生疏。 在某處存在類型不匹配-實際上是通過將字符串包裝在_T宏中發現的。

在CPP文件中包含MusicNoteLib.h之前,需要包括聲明LPFNTRACEPROC和TCHAR的標頭。 可能是Player.h,也許不應該像ChrisF建議的那樣被注釋掉,也可能是Windows標頭。

基本思想是,您需要查看編譯器抱怨的行,弄清楚這些行中的符號在哪里聲明,並包括具有這些聲明的適當的頭文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM