This code:
#ifndef WIN32
#include <pthread.h>
#endif
class MyClass
{
private:
#ifdef WIN32
CRITICAL_SECTION _mutex_obj_;
#else
pthread_mutex_t _mutex_obj_;
pthread_mutexattr_t _mutex_obj__attr_;
#endif
protected:
public:
MyClass();
virtual ~MyClass();
};
MyClass::MyClass()
{
#ifdef WIN32
InitializeCriticalSection(&_mutex_obj_);
#else
pthread_mutexattr_init(&_mutex_obj__attr_);
pthread_mutex_init(&_mutex_obj_, &_mutex_obj__attr_);
pthread_mutexattr_destroy(&_mutex_obj__attr_);
#endif
}
MyClass::~MyClass()
{
}
int main()
{
MyClass mc;
}
compiles (and runs) fine on my Ubuntu box (don't forget to link with
pthread
library).