2010-06-18 3 views
1

나는이 라이브러리로 midifiles를 저장하는 C++의 작은 응용 프로그램을 만들려고합니다. http://musicnote.sourceforge.net/docs/html/index.htmlC++/c 혼란

홈페이지에 제공되는 샘플 코드는 다음과 같습니다. 오류 C4430 : 누락 된 형식 지정자 - 가정 int로

#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 
    } 

, 나는

MusicNoteLib.h처럼 (22) 많은 오류를 비주얼 스튜디오 2008에서 컴파일되지 않습니다이 코드 조각을 얻는다. 참고 : C++가 지원하지 않는 기본-INT

내가 찾고 시작하는 오류 또는 어디를 이해하지 않습니다 ... 대신이 시간의 파일을 사용할 수 있습니다 일부 dll 파일은 있었다.

#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__ 
+0

글쎄, 오류 메시지는 어딘가에 'int foo (bar)'(바는 타입이 없음)와 같이 누락 된 타입이 있다는 것을 알려주기 때문에'int bar'라고 가정합니다. –

+1

어떤 방식 으로든이 헤더를 수정 했습니까? "player.h"가 주석 처리 된 것을 볼 수 있습니다. – ChrisF

+0

아니요! 나는 그것을 수정하지 않았다. –

답변

0

오류는이 라인에 : 나는 "분노"C/C++ 않았기 때문에

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

그것은 내가 여기에 조금 녹슬 동안이었다. 어딘가에 유형 불일치가 있습니다. 실제로는 _T 매크로에 문자열을 래핑하여 발견했습니다.

+0

고마워요. (저에게있어서) 이런 라이브러리에 뛰어 들기가 아주 어렵습니다. 저는 항상 컴파일 오류가 있습니다 ... 나는 이런 식으로 AC 스타일 명령을 보내서 고쳤습니다. MusicNoteLib :: SaveAsMidiFile (_T (" CCECCC "), _T ("Output.Mid ")); 그러나 _T가 무엇인지 의미하지는 않습니다. 홈페이지의 예제가 다운로드 가능한 코드와 일치하지 않는 것 같습니다. –

+0

@mrbuxley - C/C++을 "분노하게"했기 때문에 조금 녹슬었지만'_T '는 유니 코드 문자열을위한 문자 변환 매크로입니다 (제 생각 엔). – ChrisF

+0

위에 인용 된 줄은 LPFNTRACEPROC의 정의입니다. –

0

CPP 파일에 MusicNoteLib.h를 포함하기 전에 LPFNTRACEPROC 및 TCHAR을 선언하는 헤더를 포함해야합니다. 그것은 아마도 ChrisF가 제안한 것처럼 주석 처리해서는 안되는 Player.h 일 수도 있고 Windows 헤더 일 수도 있습니다.

기본 개념은 컴파일러가 불평하는 줄을보고, 그 줄의 기호가 어디에 선언되는지 알아 내고 그 선언이있는 적절한 헤더 파일을 포함해야한다는 것입니다.