<HTML dir=ltr><HEAD><TITLE>Re: I2C: Getting Compiation Error for application program</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText21320 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>
<DIV id=idOWAReplyText16906 dir=ltr>
<DIV dir=ltr><FONT color=#000000 size=2>Hello Matthias,</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>Thanks for the reply.</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>I got the reason from i2c mailing list on getting compilation errors. </FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>A text from the I2C mailing list :</FONT></DIV>
<DIV dir=ltr>8<---------------------------------------------------------------------------------------</DIV>
<DIV dir=ltr><FONT color=#000000 size=2>"All the above it caused by you including <linux/i2c.h>. As explained<BR>before, this is a kernel-only header file, which you must _not_ include<BR>in user-space code. You are not the only one to blame though, as in<BR>fact this header file should not be in /usr/include at all, this is a<BR>mistake which should be fixed "soon". "</FONT></DIV></DIV>
<DIV dir=ltr>
<DIV dir=ltr>--------------------------------------------------------------------------------------->8</DIV></DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>Some of the error lines are appended for your reference.</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>Now I will do the changes in the code as per above above suggestion.</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>Tnaks and Regards,</DIV>
<DIV dir=ltr>Sachin Rane</DIV>
<DIV dir=ltr><BR> </DIV>
<DIV dir=ltr><FONT size=2>> -bash-2.05b# gcc eeprom-client.c<BR>> In file included from /usr/include/asm/div64.h:1,<BR>> from /usr/include/linux/jiffies.h:9,<BR>> from /usr/include/linux/sched.h:12,<BR>> from /usr/include/linux/module.h:10,<BR>> from /usr/include/linux/i2c.h:31,<BR>> from eeprom-client.c:1:<BR>> /usr/include/asm-generic/div64.h:54:3: #error do_div() does not yet support the C64<BR>> In file included from /usr/include/linux/sched.h:12,<BR>> from /usr/include/linux/module.h:10,<BR>> from /usr/include/linux/i2c.h:31,<BR>> from eeprom-client.c:1:<BR>> /usr/include/linux/jiffies.h:84: error: parse error before "jiffies_64"<BR>> /usr/include/linux/jiffies.h:88: error: parse error before "get_jiffies_64"<BR>> In file included from /usr/include/linux/sched.h:12,<BR>> from /usr/include/linux/module.h:10,<BR>> from /usr/include/linux/i2c.h:31,<BR>> from eeprom-</FONT></DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr> </DIV></FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Matthias Fuchs [mailto:matthias.fuchs@esd-electronics.com]<BR><B>Sent:</B> Thu 9/21/2006 5:13 AM<BR><B>To:</B> linuxppc-embedded@ozlabs.org<BR><B>Cc:</B> Sachin Rane<BR><B>Subject:</B> Re: I2C: Getting Compiation Error for application program<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>On Wednesday 20 September 2006 14:51, Sachin Rane wrote:<BR>> Hi,<BR>> <BR>> I am trying to compile simple program (appended), but getting lots of<BR>compilation error.<BR>It's always helpful to see the compiler output. Could you post it?<BR><BR>> I am using Timesys Linux 2.6.13 for ppc440 evaluation board.<BR>> <BR>> Command used for compilation:<BR>> $> gcc eeprom-client.c -o eeprom-client.o<BR>Are you crosscompiling? Doesn't look like that...<BR>> <BR>> Could you help me to find out the reason behind getting the errors?<BR>> <BR>> Regards,<BR>> Sachin Rane<BR>> <BR>> <BR>><BR>8< ------------------------eeprom-client.c -------------------------------------------------------------------------------------<BR>> <BR>> #include <linux/i2c.h><BR>> #include <linux/i2c-dev.h><BR>><BR>> int main()<BR>> {<BR>> int file;<BR>> int adapter_nr = 0; /* probably dynamically determined */<BR>> char filename[20];<BR>> int addr = 0xA1; /* The I2C address */<BR>You propably have to use 0x50 here.<BR>><BR>> sprintf(filename,"/dev/i2c-%d",adapter_nr);<BR>> if ((file = open(filename,O_RDWR)) < 0)<BR>> {<BR>> exit(1);<BR>> }<BR>> <BR>> if (ioctl(file,I2C_SLAVE,addr) < 0)<BR>> {<BR>> exit(1);<BR>> }<BR>> else<BR>> {<BR>> printf("\n Able to bind the adapter");<BR>> }<BR>> return 0;<BR>> }<BR><BR>Matthias<BR></FONT></P></DIV></BODY></HTML>