Question

I want to establish build-time cross-language ABI compatibility with Waf. How would I go about checking the size of a type (or any arbitrary type-like checks), and recording it into the build configuration?

Was it helpful?

Solution

You can create a program which outputs that size. I saw this apporach on several ./configure files:

cat << EOF > test.c
#include <stdio.h>
int main ()
{
    printf("int %d\n", sizeof(int));
    return 0;
}
EOF
$(CC) test.c -o out
./out >> sizes
rm -f test.c out

Of course, with testing of erroneous cases and such.

Edit: See the waf documentation. Specially, read the run_c_code method. For saving the value of sizeof you can write to a file instead and read it from Python/Waf. Or, see the define_ret argument.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top