bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using the CommonC++ library in WIN32


From: Massimo Balestri
Subject: using the CommonC++ library in WIN32
Date: Tue, 15 May 2001 18:44:19 +0200

Hi all,
(sorry for any duplicate e-mail, I don't know exactly which reflector is currently in use);
I am trying to use CommonC++ 1.4.2. on a set of WIN32 machines (98, NT, 2000).
I use VC++ 6.0 (SP4) to compile the library.
I can compile the library without problems, but when I try to use it, each time I include
"thread.h" I get the following level-1 warnings:
--------------------------
Compiling...
threadtest.cpp
c:\workspace\ovm_code\common\commoncxx\thread.h(486) : warning C4273: 'waitThread' : inconsistent dll linkage. dllexport assumed. c:\workspace\ovm_code\common\commoncxx\thread.h(487) : warning C4273: 'delay' : inconsistent dll linkage. dllexport assumed. c:\workspace\ovm_code\common\commoncxx\thread.h(488) : warning C4273: 'yield' : inconsistent dll linkage. dllexport assumed. c:\workspace\ovm_code\common\commoncxx\thread.h(490) : warning C4273: 'getException' : inconsistent dll linkage. dllexport assumed. c:\workspace\ovm_code\common\commoncxx\thread.h(491) : warning C4273: 'setException' : inconsistent dll linkage. dllexport assumed.
Linking...
-----------------------------------
Then the simple example runs without problems, but I suppose that this is not a good sign.
My impression is that more complex examples could go into troubles.
Attached is the test code (a very simple code...)

with kind regards,
Massimo.
------------------------------
#include "config.h"
#include "thread.h"
#include "socket.h"

class ThreadTest : public Thread
{
  private:
        int  _threadID;                         // a simple user-defined thread 
identifier
        Mutex * mutex;                          // mutex shared between several 
threads

        void Run()
        {
                int i = 0 ;
                while (true)
                {
                        mutex->EnterMutex();
                        cout << "Thread ID="<< _threadID <<", loop 
number="<<(i++)<< endl;
                        mutex->LeaveMutex();
                        Sleep(20);
                }
        };

        void Final()
        {
                cout << "Thread " << _threadID <<" exiting."<< endl;
        };

  public:

        ThreadTest(int threadID, Mutex * mutexPar): _threadID(threadID)
        {
                mutex = mutexPar;       // initialise the mutex
        };

        ~ThreadTest()
        {
                Terminate();
        };

};

int main()
{
        Mutex *m = new Mutex();
        ThreadTest *thread1 = new ThreadTest(1,m);
        ThreadTest *thread2 = new ThreadTest(2,m);
        ThreadTest *thread3 = new ThreadTest(3,m);
        cout << "Starting 3 threads named 1,2,3." << endl;
        thread1->Start();
        thread2->Start();
        thread3->Start();
        sleep(5);                                               // wait 5 
seconds
        delete thread1;
        delete thread2;
        delete thread3;
        delete m;
        cout << "Main exiting." << endl;
        return 0;
}

----------------------------
Massimo Balestri
TELECOM ITALIA LAB
Multimedia Division
Via G. Reiss Romoli, 274
I 10148 TORINO (I)
Tel: + 39 011 228 6176
Fax: + 39 011 228 6299
http://www.telecomitalialab.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]