<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>&nbsp;</DIV>
<DIV dir=ltr><FONT size=2>Thanks for the reply.</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV dir=ltr><FONT size=2>A text from the I2C mailing list&nbsp;:</FONT></DIV>
<DIV dir=ltr>8&lt;---------------------------------------------------------------------------------------</DIV>
<DIV dir=ltr><FONT color=#000000 size=2>"All the above it caused by you including &lt;linux/i2c.h&gt;. 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>---------------------------------------------------------------------------------------&gt;8</DIV></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>Some of the error lines are appended for your reference.</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>Now I will do the changes in the code as per above above suggestion.</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>Tnaks and Regards,</DIV>
<DIV dir=ltr>Sachin Rane</DIV>
<DIV dir=ltr><BR>&nbsp;</DIV>
<DIV dir=ltr><FONT size=2>&gt; -bash-2.05b# gcc eeprom-client.c<BR>&gt; In file included from /usr/include/asm/div64.h:1,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/jiffies.h:9,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/sched.h:12,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/module.h:10,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/i2c.h:31,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from eeprom-client.c:1:<BR>&gt; /usr/include/asm-generic/div64.h:54:3: #error do_div() does not yet support the C64<BR>&gt; In file included from /usr/include/linux/sched.h:12,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/module.h:10,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/i2c.h:31,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from eeprom-client.c:1:<BR>&gt; /usr/include/linux/jiffies.h:84: error: parse error before "jiffies_64"<BR>&gt; /usr/include/linux/jiffies.h:88: error: parse error before "get_jiffies_64"<BR>&gt; In file included from /usr/include/linux/sched.h:12,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/module.h:10,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/include/linux/i2c.h:31,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from eeprom-</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>&nbsp;</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>&gt; Hi,<BR>&gt;&nbsp;<BR>&gt; 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>&gt; I am using Timesys Linux 2.6.13 for ppc440 evaluation board.<BR>&gt;&nbsp;<BR>&gt; Command used for compilation:<BR>&gt; $&gt; gcc eeprom-client.c -o eeprom-client.o<BR>Are you crosscompiling? Doesn't look like that...<BR>&gt;&nbsp;<BR>&gt; Could you help me to find out the reason behind getting the errors?<BR>&gt;&nbsp;<BR>&gt; Regards,<BR>&gt; Sachin Rane<BR>&gt;&nbsp;<BR>&gt;&nbsp;<BR>&gt;<BR>8&lt; ------------------------eeprom-client.c -------------------------------------------------------------------------------------<BR>&gt;&nbsp;<BR>&gt; #include &lt;linux/i2c.h&gt;<BR>&gt; #include &lt;linux/i2c-dev.h&gt;<BR>&gt;<BR>&gt; int main()<BR>&gt; {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int file;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int adapter_nr = 0; /* probably dynamically determined */<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char filename[20];<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int addr = 0xA1; /* The I2C address */<BR>You propably have to use 0x50 here.<BR>&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; sprintf(filename,"/dev/i2c-%d",adapter_nr);<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; if ((file = open(filename,O_RDWR)) &lt; 0)<BR>&gt;&nbsp;&nbsp;&nbsp; {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&gt;&nbsp;&nbsp;&nbsp;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; if (ioctl(file,I2C_SLAVE,addr) &lt; 0)<BR>&gt;&nbsp;&nbsp;&nbsp; {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<BR>&gt;&nbsp;&nbsp;&nbsp; }<BR>&gt;&nbsp;&nbsp;&nbsp; else<BR>&gt;&nbsp;&nbsp; {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("\n Able to bind the adapter");<BR>&gt;&nbsp;&nbsp;&nbsp; }<BR>&gt;&nbsp;&nbsp;&nbsp; return 0;<BR>&gt; }<BR><BR>Matthias<BR></FONT></P></DIV></BODY></HTML>