2

I'm be surprised to learn type long and time_t are 4-byte sized in this HP-UX 11.31(IA64). May I ask why?

My environment:

$ uname -a
HP-UX bdev1 B.11.31 U ia64 0999202893 unlimited-user license

$ cat /usr/include/sys/_time_t.h
......
#  ifndef _TIME_T
#    define _TIME_T
#    ifdef _KERNEL
typedef int32_t time_t;
#    else /* !_KERNEL */
_NAMESPACE_STD_START
typedef long time_t;
_NAMESPACE_STD_END
#    endif /* !_KERNEL */
#  endif /* _TIME_T */

My code:

$ cat sizeof.cpp

#include <iostream>
#include <ctime>

#define PRINT_SIZE(a) \
        std::cout << #a << ": " << sizeof(a) << std::endl

int main(void)
{
        PRINT_SIZE(long);
        PRINT_SIZE(time_t);
        return 0;
}

$ aCC sizeof.cpp

$ ./a.out
long: 4
time_t: 4

Anybody could help me to find a way making time_t to 64-bit by aCC?

j0k
  • 22,600
  • 28
  • 79
  • 90
van
  • 213
  • 1
  • 3
  • 10

1 Answers1

3

I have a hunch that for whatever reason g++ has decided to output 32-bit code on your HP-UX system. You can change the build environment with the -mlp64 flag, like so:

$ g++ -Wall -mlp64 sizeof.cpp

If you're using aCC, you use +DD64:

$ aCC +DD64 sizeof.cpp

The object format for HP-UX 11i v2 is ELF, so you can use the +DD64 option to generate LP64 code. (source)

user7116
  • 63,008
  • 17
  • 141
  • 172
  • I sorry to forget to point out I use aCC at work. So the problem is how to use aCC to solve it. I reedit my question. – van Apr 27 '12 at 01:30
  • Yes, I found this arg too. But why do the program down while year of time up 2040. I suggest it was time_t limit, but now be proved not. – van Apr 27 '12 at 01:48