Ok, I did everything and more, now it compiles. But when it triest ot create the .exe, it gives me this:
Code:
C:\Borland\BCC55\Bin>BCC32 C:\Threadtest.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\Threadtest.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '__beginthread' referenced from C:\BORLAND\BCC55\BIN\
THREADTEST.OBJ
And my code is now:
Code:
#define __MT__
#include <windows.h>
#include <iostream>
#include <process.h>
using namespace std;
CRITICAL_SECTION CSector;
void Gravity(void *) {
int y, x;
x = 1;
for(y=0; y <= x; y++) {
EnterCriticalSection(&CSector);
cout << "Gravity";
LeaveCriticalSection(&CSector);
}
}
void Move(void *) {
int y, x;
x=1;
for(y=0; y <= x; y++) {
EnterCriticalSection(&CSector);
cout << "Move";
LeaveCriticalSection(&CSector);
}
}
int main() {
HANDLE h[2];
InitializeCriticalSection(&CSector);
h[0] = (HANDLE)_beginthread(Gravity, 0, NULL);
h[1] = (HANDLE)_beginthread(Move, 0, NULL);
WaitForMultipleObjects(2, h, TRUE, INFINITE);
DeleteCriticalSection(&CSector);
return 0;
}
I really hate thoes .obj errors... How do I fix this?