#include<altivec> fails on darwin

Kaspar Fischer fischerk@inf.ethz.ch
Wed Aug 7 10:39:00 GMT 2002


Dear developers,
I have just build gcc-3.1.1 on MacOS 10.1.5 and tried to compile the 
following program with Altivec instructions:

  #include <altivec.h> // (*)

  int main() {
    vector unsigned char  v0;
    vector unsigned short v1;
    int     g10;

    g10 = 0;
    v1 = vec_splat_u16 ( 9 );
    v0 = vec_lvsl ( g10, (int *)&v1 );
    v1 = vec_sr ( ( vector unsigned short ) v0,  v1 );

    return 0;
  }

That is, I put the above lines into the file constants.c and did a

   g++ -Wa,-force_cpusubtype_ALL -mabi=altivec -maltivec \
   constants.c -o tmp

This produces a huge number of errors, all similar to the first one:

In file included from constants.c:1:
/usr/local/gcc-3.1.1/lib/gcc-lib/powerpc-apple-
darwin5.5/3.1.1/include/altivec.h:124:
 declaration
   of C function `vector float vec_ctf(vector int, char)' conflicts with
/usr/local/gcc-3.1.1/lib/gcc-lib/powerpc-apple-
darwin5.5/3.1.1/include/altivec.h:123:
 previous
   declaration `vector float vec_ctf(vector unsigned int, char)' here
...

However, if I change the line marked with a (*) in the original program 
to:

   #include "/usr/local/gcc-3.1.1/lib/gcc-lib/powerpc-apple-
darwin5.5/3.1.1/include/alt\
ivec.h"

then the program compiles fine.  What am I doing wrong?

Many thanks for your help,
Kaspar




More information about the Gcc mailing list