lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> While ANSI allows sizeof(void (*)()) to be > sizeof(void*), its pretty
> unusual (I've never seen it). IIRC, traditional/pre-ANSI C required
> any ptr, including functions pointers, to be castable to void* without
> loss.

Btw, I keep this code around for a quick check of machine sizes, in
case anybody else finds it useful:

% cat bin/sz.c
#include<inttypes.h>
#include<stdio.h>
#include<stddef.h>
#include<stdlib.h>

#define SZ(x) printf("%2zd bytes " #x "%s\n", sizeof(x), (0 > (x) -1)
? "" : " (unsigned)")

typedef void function(void);

int main()
{
    SZ(void*);
    SZ(function*);
    SZ(char);
    SZ(short);
    SZ(int);
    SZ(long);
    SZ(long long);
    SZ(float);
    SZ(float);
    SZ(double);
    SZ(long double);
    SZ(time_t);
    SZ(suseconds_t);
    SZ(pid_t);
    SZ(wchar_t);
    SZ(size_t);
    SZ(ptrdiff_t);
    SZ(ssize_t);
    SZ(intmax_t);
    SZ(uintmax_t);

    return 0;
}