We skipped winmm and compiled it simply as windows-thread. It printed messages well.
> c:\aaa\bin\make.exe all
mingw32-g++ -Wall -O3 -I C:\MinGW\include\ -L C:\MinGW\lib -l gdi32 -lws2_32 -lwsock32 -o main.o -c main.cpp
mingw32-g++ main.o -Wall -O3 -I C:\MinGW\include\ -L C:\MinGW\lib -l gdi32 -lws2_32 -lwsock32 -o winmain_001.exe
> .\winmain_001.exe
main starts. 001
main starts.
Animation_5times_thread starts.
||
Animation_5times_thread ends.
we can create a thread.allocaton well:
main ends.
main.cpp Mon Apr 19 17:20:16 2021 1 :#include2 :#include 3 :#include 4 : 5 ://#include "sounds-011.h" 6 : 7 :using namespace std; 8 : 9 :char* m_data = NULL; 10 :int m_bufferSize = 0; 11 :int b_data[255]; 12 : 13 :DWORD WINAPI Animation_5times_thread ( LPVOID hdc ) ; 14 : 15 :int main() { 16 : DWORD ThreadId; 17 : HANDLE ThreadHandle; 18 : HDC hdc; 19 : 20 : cout << "main starts. 001" << endl; 21 : printf ("main starts.\r\n"); 22 : Sleep(1000); 23 : 24 : ThreadHandle = CreateThread( NULL, /* default security attributes */ 0, /* default stack size */ 25 : Animation_5times_thread, /* thread function */ (LPVOID)&hdc, /* parameter to thread function */ 0, /* default creation flags */ &ThreadId); 26 : 27 : //returns the thread identifier 28 : if (ThreadHandle != NULL){ 29 : //now wait for the thread to finish 30 : WaitForSingleObject(ThreadHandle,INFINITE); 31 : //close the thread handle 32 : CloseHandle(ThreadHandle); 33 : printf("we can create a thread."); 34 : } 35 : 36 : int dataLength = 255; 37 : 38 : // Allocate the array 39 : m_data = new char[m_bufferSize = dataLength]; 40 : 41 : printf("allocaton well: \r\n"); 42 : 43 :// SoundEffect* as = (SoundEffect*) new SoundEffect( (int*) b_data, 255); 44 : 45 : printf ("main ends.\r\n"); 46 : return 0; 47 :} 48 :