|
It looks like the culprit is in /usr/include/time.h:
#ifdef __DECC
#pragma extern_prefix "_P"
#else
#define asctime_r(__a,__b) _Pasctime_r(__a,__b)
#define ctime_r(__a,__b) _Pctime_r(__a,__b)
#define gmtime_r(__a,__b) _Pgmtime_r(__a,__b)
#define localtime_r(__a,__b) _Plocaltime_r(__a,__b)
#endif /* __DECC */
#endif /* !_LIBC_POLLUTION_H_ */
extern char *asctime_r __((const struct tm *, char *));
extern char *ctime_r __((const time_t *, char *));
extern struct tm *gmtime_r __((const time_t *, struct tm *));
extern struct tm *localtime_r __((const time_t *, struct tm *));
So the localtime_r is being macroized to _Plocaltime_r
with no corresponding prototype declared.
So I think the maintainers of time.h should be notified (see
CXXC_BUGS note 3535.3 for instructions). For now they
can workaround this problem by adding the declarations to
the code directly, i.e.:
// foo3.cxx
#include <time.h>
// add these prototypes to workaround problem in time.h
extern "C" {
extern char * _Pasctime_r __((const struct tm *, char *));
extern char * _Pctime_r __((const time_t *, char *));
extern struct tm *_Pgmtime_r __((const time_t *, struct tm *));
extern struct tm *_Plocaltime_r __((const time_t *, struct tm *));
}
void foo()
{
time_t clock;
struct tm res;
localtime_r(&clock, &res);
}
main() {}
|
| This is a problem in the /usr/include/time.h header file, that has since been
fixed in Digital UNIX V4.0B.
Here is the diff:
diff time.h /usr/include/time.h
143,146c143,146
< extern char * __P_C(asctime_r) __((const struct tm *, char *));
< extern char * __P_C(ctime_r) __((const time_t *, char *));
< extern struct tm * __P_C(gmtime_r) __((const time_t *, struct tm *));
< extern struct tm * __P_C(localtime_r) __((const time_t *, struct tm *));
---
> extern char *asctime_r __((const struct tm *, char *));
> extern char *ctime_r __((const time_t *, char *));
> extern struct tm *gmtime_r __((const time_t *, struct tm *));
> extern struct tm *localtime_r __((const time_t *, struct tm *));
The first is the V4.0B file with the fix.
You could either upgrade to V4.0B or look for a patch at
http://www.zk3.dec.com/dupatchwww/
Or you could "patch" the file yourself, with the above edit.
This is not a C++ compiler problem.
-Jeff
|
| Note that all versions of Digital UNIX V4.0* will report V4.0 when using
"uname -r". For example:
% uname -a
OSF1 isaiah.zk3.dec.com V4.0 386 alpha
% uname -a
OSF1 quarry.zk3.dec.com V4.0 564 alpha
The first contained the time.h bug, the second had the fix.
As you can see, V4.0 doesn't always equal V4.0!
(The first is V4.0, the second V4.0B)
One good resource that I found is this table of UNIX revisions at
http://www.zk3.dec.com/unix_versions.html
For the V4.0 family, here is the pertinent info:
4.0 Platinum pt 12 Jun 1996 386 OSF400 11
4.0a PTA pta 12 Sep 1996 464 OSF405 9
4.0b PTB ptb 13 Dec 1996 564 OSF410 14
4.0c PT-HW1 pthw1 est 4/97 13,
4.x PTmin ptc est 10/97 12
4.x Steel steel est Q1CY98 10
Note that to distinguish V4.0 from V4.0a from V4.0b, you need to look at
the rev number in addition to the version number.
-Jeff
|