[macstl-dev] gcc 3.4.2 "keywords" bool and pixel
Michael LeBlanc
leblanc at skycomputers.com
Wed Jun 8 03:53:34 WST 2005
Release 3.4.2 replaced one sort of silliness with others. If you
include <altivec.h>, you get by some magic macros for these words:
#define __pixel __attribute__((altivec(pixel__))) unsigned short
#define __bool __attribute__((altivec(bool__))) unsigned
#define __vector __attribute__((altivec(vector__)))
#define pixel __pixel
#define bool __bool
#define vector __vector
Without the include, all 6 words stand for themselves, and bool is a
builtin type. I wrote a little program to display some of this stuff
and got a big surprise. See the line below marked with "What!!!"
Aside from this weirdness, MacSTL looks like it will be a lot cleaner
with this release and beyond. But, vec <pixel, 8> fails to instantiate
and I have not yet come up a specialization that will compile.
/usr/gcc-3.4.2/bin/c++ -O -I/home/leblanc/macstl/macstl p.cpp -o mike
-DMIKE
p.cpp:10: warning: `altivec' attribute ignored
./mike
with <altivec.h>
sizeof(pixel) = 2
#define pixel = __attribute__((altivec(pixel__))) unsigned short
#define vector = __attribute__((altivec(vector__)))
sizeof(bool) = 16 What!!!
#define bool = __attribute__((altivec(bool__))) unsigned
/usr/gcc-3.4.2/bin/c++ -O -I/home/leblanc/macstl/macstl p.cpp -o mike
./mike
without <altivec.h>
sizeof(bool) = 1
#define bool = bool
Here's the program ...
$ cat p.cpp
#define STR2(x) #x
#define STR(x) STR2(x)
#include <stdio.h>
#ifdef MIKE
#include <altivec.h>
pixel ppp;
char *sss = STR(pixel);
#endif
bool aaa;
char *bbb = STR(bool);
char *vvv = STR(vector);
int main ()
{
#ifdef MIKE
printf ("\n\nwith <altivec.h>\n");
printf (" sizeof(pixel) = %d\n", sizeof(ppp));
printf (" #define pixel = %s\n", sss);
printf (" #define vector = %s\n", vvv);
#else
printf ("\n\nwithout <altivec.h>\n");
#endif
printf (" sizeof(bool) = %d%s\n",
sizeof(aaa),sizeof(aaa)>1?"\tWhat!!!":"");
printf (" #define bool = %s\n\n", bbb);
return 0;
}
More information about the macstl-dev
mailing list