Boost logo

Boost Users :

From: Stephen Jackson (stephen.jackson_at_[hidden])
Date: 2003-03-04 18:44:03


Michael Hunley wrote:
>
> Disclaimer: I am relatively new to gcc, linux and Boost. I'm hoping
> someone out in the group who is much more knowledgable about all of them
> can help me get past a hurdle in code I am porting from Windows. I am
> getting a vague error message from g++ (gcc 3.2-7 under Redhat Linux 8.0)
> in my code using the Boost scoped_lock.
>

[ snip ]

>
> The error is "ISO C++ forbids declarations of 'type name' with no
type". I
> get that error on several lines, but most notably on a simple
declaration like:
> PScopedLock Lock(MyMutex);
>

Hi Michael,

I think you will need to post some more code; I have tried the code you
posted, including your simple declaration, on the same platform (gcc
3.2-7 under Redhat Linux 8.0) - with boost 1.29.0. This compiles without
error. (See below.)

Regards,

Stephen Jackson

-- 
stephen.jackson_at_[hidden]       http://www.scribitur.com/spj/
gcc -c -Iboost_1_29_0 testit.cpp  -Wall
#include "boost/thread/mutex.hpp"
// Begin your posted code
class PMutex
{
public:
          PMutex() {}
          virtual ~PMutex() {}
protected:
          boost::mutex    m_Mutex;
          friend class PScopedLock;
};
class PScopedLock
{
public:
          explicit PScopedLock( PMutex& M )       : 
m_ScopedLock(M.m_Mutex) {}
          virtual ~PScopedLock() {}
          static PScopedLock*     Create( PMutex& M ) { return
(PScopedLock*) ::new PScopedLock(M); }
          void Destroy( void ) { delete this;     }
protected:
          void* operator new(size_t) {}   /* disallowed, must declare on 
            the stack */
          boost::mutex::scoped_lock       m_ScopedLock;
          friend class PCondition;
};
// End your posted code
void this_is_a_test()
{
	PMutex MyMutex;
	PScopedLock Lock(MyMutex); // Compiles OK
}

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net