Re: [Nagios-devel] macro_x madness heads up

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] macro_x madness heads up

Post by Guest »

On 11/05/2010 12:12 PM, Ton Voon wrote:
>
> On 5 Nov 2010, at 09:45, Andreas Ericsson wrote:
>
>> Using this completely untested program, what output do you get?
>>
>> #include
>> #include
>> #include
>> #define psize(type) printf("sizeof(" #type ") = %d\n", sizeof(type))
>>
>> int main(int argc, char **argv)
>> {
>> psize(time_t);
>> psize(__darwin_suseconds_t);
>> psize(int);
>> psize(long);
>> psize(off_t);
>> psize(void *);
>> psize(long long);
>> return 0;
>> }
>
> I get:
>
> $ ./a.out
> sizeof(time_t) = 4
> sizeof(__darwin_suseconds_t) = 4
> sizeof(int) = 4
> sizeof(long) = 4
> sizeof(off_t) = 8
> sizeof(void *) = 4
> sizeof(long long) = 8
>
> macbook 10.5, 32bit.
>

Basically, size_t == int == long gcc should just shut the fsck up
about those.

time_t == __darwin_suseconds_t. There's no portable way to print
time_t except casting the argument to unsigned long, so I'll do
that.

The only thing that differs between your system and mine is off_t
not being same size as (void *), which is extremely odd indeed.
It really should be the same as a 'long' on all systems (long long
is C99-ish, so we can't really use that).

size_t gets its printf() format spec from C99 as well. The portable
way of printing it without warnings is to cast it to unsigned long
and use %lu in the format string.

Yuck and yuck for such types tbh.

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked