This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: threads in C++


Dima Volodin wrote:
> 
> Jifl wrote:
> >C++ defines that if a static class member function is declared as e.g.
> >static void *func(void *), then if you take the address of this function,
> >it has the required type for pthread_create. This is well-defined behaviour
> >in C++.
> 
> Would you please give me the exact reference to where in the Standard
> this behavior is defined? Or just save your time and see section 9.2.5
> in _The C++ Programming Language_, Third Edition, by Bjarne Stroustrup.

I've had a look at the standard, and in a sense we're both right ;-). There
is a distinction between the linkage of the member's name and the linkage of
the member's type. (see sect 7.5 para 4).

So I tried the following example which comes pretty much straight from this
para. According to the std, this defines a data member such that the name
has C++ language linkage and the type is pointer to C function:

extern "C" typedef void FUNC_c();

class C {
public:
        static FUNC_c* q;
};

Compiling with 2.95.2, I get:

$ gcc -c flibble.cxx
flibble.cxx:1: multiple storage classes in declaration of `FUNC_c'

g++ bug? 

Jifl


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]