From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,fa038cb3838bfb7a X-Google-Attributes: gidfee84,public From: "Brian J. McCarthy" Subject: Re: DEC C++ cmplr V5.5 Name clash Date: 1997/09/16 Message-ID: <341E25A5.5F284BB1@hndymn.zko.dec.com>#1/1 X-Deja-AN: 273554942 References: <01bcb918$c110f940$6d14d9c2@KeithAlexander-Buckley.vegauk.co.uk> Organization: Digital's / C/C++ Compilers & RTLs Newsgroups: comp.unix.osf.osf1 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 and the STL header file 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 (VMS) template ^ %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 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 #include #include int input [4] = { 1, 5, 7, 2 }; int main() { tms* tmsp = new tms; // use times() the function clock_t mytimes = times(tmsp); // use multiply the STL function object int total = accumulate (input, input + 4, 1, multiply ()); } // t.h #ifndef _T_H #define _T_H #define times multiply #include // header file that includes #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 -----------------------------------------------------------------------