Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: "Brian J. McCarthy" <mccarthy@hndymn.zko.dec.com>
Subject: Re: DEC C++ cmplr V5.5 Name clash
Date: 1997/09/16	[thread overview]
Message-ID: <341E25A5.5F284BB1@hndymn.zko.dec.com> (raw)
In-Reply-To: 01bcb918$c110f940$6d14d9c2@KeithAlexander-Buckley.vegauk.co.uk


Keith Alexander-Buckley wrote:
> 
> Has anyone else noticed a name clash in the DEC C++ compiler (v5.5-004)?
> 
> The offending names are the times template function in the STL functional
> header and the use of the times function as an extern prototye in the
> sys/times.h header which is included by the stopwatch.hxx header.  Both
> headers are shipped with the compiler.
> 
> As it stands there appears to be no way of using stopwatches in STL based
> apps without hacking the header.
> 
> Anyone know of any other work around?
> 

Keith, 

We release noted this issue with the compiler and in V5.6 and above 
the STL function object name was changed to "multiplies" (since 
other members of the C++ committee decided the name conflict was
annoying...)

Here is the section of the release notes that deals with this:


If you include the <sys/times.h> and the STL header file
<functional> in the same program, you will get this error:

(Digital UNIX)
cxx: Error: /usr/include/cxx/functional, line 62: In this declaration,
"times"
has no linkage and has a prior declaration in this scope at line number
89 in
file /usr/include/sys/times.h.
template <class T>

(VMS)
        template <class T>
        ^
%CXX-E-NOLINKAGE, In this declaration, "times" has no linkage and has a
prior
 declaration in this scope at line 129 in TIMES.
                At line number 62 in CXXL$:[STD_BUILD]FUNCTIONAL.;1.

        }

The problem is that times is declared in <sys/times.h> as a
function name and in the STL header file functional as a function
object that does multiplication.

Workaround: Eventually this conflict will be solved by putting the
STL times inside the std namespace. Until our compiler has namespaces
we recommend redefining the STL "times" to the name "multiply" before
the first inclusion of the header file functional, i.e.:

// main.cxx
#include <sys/times.h>
#include <t.h>
#include <numeric>

int input [4] = { 1, 5, 7, 2 };

int main()
{
        tms* tmsp = new tms;
        // use times() the <sys/times.h> function
        clock_t mytimes = times(tmsp);
        // use multiply the STL function object
        int total = accumulate (input, input + 4, 1, multiply<int> ());
}


// t.h
#ifndef _T_H
#define _T_H

#define times multiply
#include <vector> // header file that includes <functional>
#undef times

#endif

Notice that the vector header file and its #define wrapper has to
be placed in a separate header file (t.h) in order for automatic
instantiation to work properly.




-- 
-----------------------------------------------------------------------
Brian J. McCarthy                  | mailto:mccarthy@hndymn.zko.dec.com
Digital Equipment Corp. Nashua, NH | DEC C++ Class Libraries
-----------------------------------------------------------------------



      reply	other threads:[~1997-09-16  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-04  4:00 DEC C++ cmplr V5.5 Name clash Keith Alexander-Buckley
1997-09-16  4:00 ` Brian J. McCarthy [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox