* DEC C++ cmplr V5.5 Name clash
@ 1997-09-04 4:00 Keith Alexander-Buckley
1997-09-16 4:00 ` Brian J. McCarthy
0 siblings, 1 reply; 2+ messages in thread
From: Keith Alexander-Buckley @ 1997-09-04 4:00 UTC (permalink / raw)
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?
Thanks,
Keith
----------------------------------------------------------------------------
--
Keith Alexander-Buckley,
Principal Software Engineer,
Vega Group PLC
kalexand@vega.co.uk
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: DEC C++ cmplr V5.5 Name clash
1997-09-04 4:00 DEC C++ cmplr V5.5 Name clash Keith Alexander-Buckley
@ 1997-09-16 4:00 ` Brian J. McCarthy
0 siblings, 0 replies; 2+ messages in thread
From: Brian J. McCarthy @ 1997-09-16 4:00 UTC (permalink / raw)
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
-----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-09-16 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-04 4:00 DEC C++ cmplr V5.5 Name clash Keith Alexander-Buckley
1997-09-16 4:00 ` Brian J. McCarthy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox