So far, you all have been a greate resource so I am asking one last question (hopefully).
I am threading some database functions and am passing a struct via the CreateThread(...) function. No problem there. (See definition of the struct)
I am initializing in the main() like so:Code:typedef struct _dbThreadData{ CString dbData1; CString dbData2; char dbTime[6]; CString dbCommand; CString dbStatus; long dbProcess; }DBTHREAD, *PDBTHREAD;
The compiler barked that the dbth struct was not initializedCode:PDBTHREAD dbth; dbth-> dbData1 = Data1; dbth->dbData2 =Data2; dbth->dbStatus = stat; sprintf(dbth->dbTime , "%d", stopTime); dbth->dbProcess = 1; // create thread here for mdtMetrics dbThreadHandle[1] = CreateThread( NULL, // default security attributes 0, // use default stack size dbThreadProc, dbth, // argument to thread function 0, // use defailt creation flags &dwThreadID // returns thead identifier );, so investigation shows that the HeapAlloc(...) might be needed.C:\Visual Studio Projects\Poller\PollerDlg.cpp(1096) : warning C4700: local variable 'dbth' used without having been initialized
I added:but am now getting teh error:Code:PDBTHREAD dbth; dbth = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DBTHREAD));.C:\Visual Studio Projects\Poller\PollerDlg.cpp(1095) : error C2440: '=' : cannot convert from 'void *' to 'struct _dbThreadData *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Am I doing this part right??? Since i am declaring the struct as a pointer (_dbThreadData *dbth), is HeapAlloc(...) necessary to initialize the struct? I am missing something but cannot figure out what? Suggestions?




Reply With Quote