bug-commoncpp
[Top][All Lists]
Advanced

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

Re: using the CommonC++ library in WIN32


From: David Sugar
Subject: Re: using the CommonC++ library in WIN32
Date: Tue, 15 May 2001 20:43:17 -0400
User-agent: Mozilla/5.0 (X11; U; Linux 2.4.4-1mdkxfs i686; en-US; 0.8) Gecko/20010409

As I do not spend any time at present developing on the Win32 platform, I do not have any immediate suggestion, however, I assume there are others on the list that do and will. I do have in mind to start an interesting project that will include a win32 target, however, so I expect I will also spend a lot of time finding these leftover issues with the win32 build very soon :).

Massimo Balestri wrote:

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


_______________________________________________
Bug-commoncpp mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-commoncpp






reply via email to

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