|
From: | Elias Mårtenson |
Subject: | Re: [Bug-apl] using c libs in apl? |
Date: | Fri, 10 Feb 2017 14:04:18 +0800 |
I believe passing/returning struct is actually compiler dependent (man gcc and /struct-return).
What you are talking about implementation dependent type and alignment is a real problem.
Actually without fully preprocessing the headerfiles, we can never be sure about system/architecture dependent types.
In <sys/time.h>, we have
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
the size of time_t and suseconds_t are architecture dependent. The only reliable way that I
know of is,
gcc -x c -include stdio.h -include sys/time.h -o /tmp/tt - <<<'int main()
{printf("%d %d %d\n",sizeof(struct timeval),sizeof(time_t),sizeof(suseconds_t));}' && /tmp/tt && rm /tmp/tt
[Prev in Thread] | Current Thread | [Next in Thread] |