M
mrsinger
I have a multi-threaded application (non posix) that needs to put a
semaphore around the constructor/destructor of a class. So, I have a
static variable which is the semaphore. Now, I have to make an OS call
to init the variable before any constructor for the class is called.
The code below give me a link error:
unresolved external symbol "private: static int test::sem"
I've been searching through old posts, but can't find anything anything
close. What is the correct way to do this?
---------------------
void OS_CreateSem(int *sem)
{
*sem = 1;
}
class test
{
private:
static int sem;
public:
static void makesem()
{
OS_CreateSem(&sem);
}
test()
{
//take semaphore
//do construction stuff
//release semaphore
}
};
void main()
{
test::makesem();
class test()
}
semaphore around the constructor/destructor of a class. So, I have a
static variable which is the semaphore. Now, I have to make an OS call
to init the variable before any constructor for the class is called.
The code below give me a link error:
unresolved external symbol "private: static int test::sem"
I've been searching through old posts, but can't find anything anything
close. What is the correct way to do this?
---------------------
void OS_CreateSem(int *sem)
{
*sem = 1;
}
class test
{
private:
static int sem;
public:
static void makesem()
{
OS_CreateSem(&sem);
}
test()
{
//take semaphore
//do construction stuff
//release semaphore
}
};
void main()
{
test::makesem();
class test()
}