Cannot convert int to LPUNIT
I have an error with this codie.
'midiInGetID' : cannot convert parameter 2 from 'int *' to 'LPUINT'
What does int *
and LPUNIT
mean?
struct midi_in_list_node
{
int midi_in_number;
HMIDIIN midi_in;
struct midi_in_list_node *next_midi_in_list_node;
};
struct midi_in_list_node *first_midi_in_list_node = NULL;
void CALLBACK midi_in_handler(HMIDIIN midi_in, UINT msg_type, DWORD user_data, DWORD midi_msg, DWORD param2)
{
int midi_in_number;
midiInGetID(midi_in, &midi_in_number);
if (msg_type == MIM_DATA)
{
After changing to UINT, I have other error:
1>------ Build started: Project: MIDI, Configuration: Debug Win32 ------
1>Compil开发者_开发知识库ing...
1>MIDI.cpp
1>c:\users\wildfire\documents\visual studio 2008\projects\midi\midi\midi.cpp(103) : warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(324) : see declaration of 'sscanf'
1>Linking...
1>MIDI.obj : error LNK2019: unresolved external symbol __imp__midiInGetID@8 referenced in function "void __stdcall midi_in_handler(struct HMIDIIN__ *,unsigned int,unsigned long,unsigned long,unsigned long)" (?midi_in_handler@@YGXPAUHMIDIIN__@@IKKK@Z)
1>MIDI.obj : error LNK2019: unresolved external symbol __imp__midiInClose@4 referenced in function "int __stdcall control_handler(unsigned long)" (?control_handler@@YGHK@Z)
1>MIDI.obj : error LNK2019: unresolved external symbol __imp__midiInStop@4 referenced in function "int __stdcall control_handler(unsigned long)" (?control_handler@@YGHK@Z)
1>MIDI.obj : error LNK2019: unresolved external symbol __imp__midiInStart@4 referenced in function _main
1>MIDI.obj : error LNK2019: unresolved external symbol __imp__midiInOpen@20 referenced in function _main
1>C:\Users\Wildfire\Documents\Visual Studio 2008\Projects\MIDI\Debug\MIDI.exe : fatal error LNK1120: 5 unresolved externals
1>Build log was saved at "file://c:\Users\Wildfire\Documents\Visual Studio 2008\Projects\MIDI\MIDI\Debug\BuildLog.htm"
1>MIDI - 6 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
In response to your new problems, you need to link your project against the winmm.lib
static library. To do that, open up your Project Settings and go to Linker → Input → Additional Dependencies and add winmm.lib
to that text box.
When you get errors like "Unresolved external symbol", that means you're not linking against the correct library. To figure out what the correct library is, look at the documentation (e.g. here is the documentation for midiInGetID
). Under the section Requirements, it lists winmm.lib
as the required library.
LPUNIT
is not the same as LPUINT
. LPUINT
= L ong P ointer to U nsigned int.
Just do
UINT midi_in_number;
midiInGetID(midi_in, &midi_in_number);
精彩评论