crazyjaap n00b
Joined: 31 Mar 2005 Posts: 7 Location: Netherlands
|
Posted: Thu Mar 31, 2005 10:23 am Post subject: (kernel) headers glue in /usr/include/linux |
|
|
Hello all,
Since monday, I can't compile a program anymore, which compiled fine last
week.
It is rather simple (see below...).
I also know (partly) why it doesn't compile anymore; when I take the
/usr/include/linux/* from 2004.3 stage 3 it works fine, but apparently
these files are changed since this weekend (emerge sync && emerge -uv
system && emerge -uv world )
When I look into the problem in more detail, I notice the following:
Current version i2c.h and i2c-dev.h:
/* $Id: i2c.h,v 1.68 2003/01/21 08:08:16 kmalkki Exp $ */
/* $Id: i2c-dev.h,v 1.13 2003/01/21 08:08:16 kmalkki Exp $ */
When I compile my program:
In file included from distance.c:5:
/usr/include/linux/i2c-dev.h:37: error: parse error before '*' token
/usr/include/linux/i2c-dev.h:42: error: parse error before '*' token
/usr/include/linux/i2c-dev.h:44: error: parse error before '}' token
Versions in kernel-2.6.11.5 directory:
/* $Id: i2c.h,v 1.68 2003/01/21 08:08:16 kmalkki Exp $ */
/* $Id: i2c-dev.h,v 1.13 2003/01/21 08:08:16 kmalkki Exp $ */
Version from gentoo 2004.3 stage3 (x86):
/* $Id: i2c.h,v 1.46 2001/08/31 00:04:07 phil Exp $ */
/* $Id: i2c-dev.h,v 1.9 2001/08/15 03:04:58 mds Exp $ */
With this last version (2004.3 stage3) the program compiles fine.
Since when are these headers updated? Were to look for more help?
greetingz,
Jaap Crezee
The Netherlands
------------
//distance.c:
#include <stdio.h>
#include <time.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <sys/time.h>
#include <fcntl.h>
#include <err.h>
#define AANTAL 35
int file;
int chip_open()
{
int dummy;
file = open("/dev/i2c/0", O_RDWR);
dummy = ioctl(file, I2C_SLAVE, 0x21);
return dummy;
}
int chip_close()
{
int dummy;
dummy = close(file);
}
int chip_write(int value)
{
return (int)i2c_smbus_write_byte(file, (__u8)value);
}
int chip_read()
{
return (int)i2c_smbus_read_byte(file);
}
int main(int argc, char *argv[])
{
struct timeval tt[AANTAL];
struct timeval t1, t2;
__u8 dummy[AANTAL];
long blaat1, blaat2;
register int counter, counter2;
int distance;
__u8 val1, val2, val;
//chip_open(0x21);
chip_open();
val1 = 0x1;
val2 = 0x0;
gettimeofday(&t1, 0);
for (counter2=0; counter2<(AANTAL*3); counter2++)
{
i2c_smbus_write_byte(file, val1);
usleep(10);
i2c_smbus_write_byte(file, val2);
for (counter=0; counter<AANTAL; counter++)
{
dummy[counter] = i2c_smbus_read_byte(file);
//printf("%d\n", dummy[counter]);
}
distance = 0;
for (counter=0; counter<AANTAL; counter++)
{
val = dummy[counter];
if ((val & 0x2) == 0x2)
{
distance++;
}
else
{
break;
}
}
usleep(100);
printf("Distance: %d ", distance);
usleep(10);
}
gettimeofday(&t2, 0);
blaat1 = t2.tv_sec - t1.tv_sec;
blaat2 = t2.tv_usec - t1.tv_usec;
if (blaat2 < 0)
{
blaat2 = abs(blaat2);
blaat1++;
}
printf("start: %d,%d end: %d, %d diff: %d,%d\n dists/sec:%d\n", t1.tv_sec, t1.tv_usec, t2.tv_sec, t2.tv_usec,
blaat1, blaat2, (AANTAL*3)/blaat1);
chip_close();
} |
|