<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: sizeof problem in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527907#M697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sat Jan 28 14:58:38 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: kayoda&lt;/STRONG&gt;&lt;BR /&gt;Are you kidding?&lt;BR /&gt;What do you think is (uint8_t)256 = (uint8_t)0x100 ?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't understand... what is it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh my god, you're right - I'm totally .... well not my day... it's 255 (max value for 8bit number) + 1, which is zero...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;damn it. Sorry...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;edit: no, I'm still stupid. Changing it to uint32_t (which is unsigned int) doesn't help at all, I still get 0 for sizeof(buffer).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 02:52:42 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T02:52:42Z</dc:date>
    <item>
      <title>sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527903#M693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sat Jan 28 14:41:17 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having a bad day I think... nothing seems to work &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Not it's time for basic functions: sizeof seems to well ignore me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have the following code&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#define UART_RING_BUFSIZE256
uint8_t buffer[UART_RING_BUFSIZE];
uint8_t z = (uint8_t)sizeof(buffer);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;Why would z equal to zero (0) ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I a simple test aside, on my linux box:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#define SIZE 10
int main()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int a[SIZE];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("size of a=%i\n", (int)sizeof(a));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;it prints "size of a=40".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ps: sizeof(uint8_t); gives me 1, so my guess would be to get 256*1 from sizeof(buffer)... wtf?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527903#M693</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527904#M694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sat Jan 28 14:51:18 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Wow, this is getting better and better:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I put this instead of using sizeof, because I know the size, right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;uint8_t buflen = (uint8_t)UART_RING_BUFSIZE;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;Again the compiler just didn't care and I got buflen equal to zero!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh shit I just got to the definition of uint8_t - it's&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;typedef unsigned char uint8_t;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why is it called int if it's a char? &lt;SPAN class="lia-unicode-emoji" title=":disappointed_face:"&gt;&lt;LI-EMOJI id="lia_disappointed-face" title=":disappointed_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527904#M694</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527905#M695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ex-kayoda on Sat Jan 28 14:56:15 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you kidding?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What do you think is (uint8_t)256 = (uint8_t)0x100 ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527905#M695</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527906#M696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sat Jan 28 14:57:11 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#define SIZE 10
typedef unsigned char uint8_t;
int main()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t a[SIZE];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("size of a=%i\n", (uint8_t)sizeof(a));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;This still gives me "size of a=10" (on my linux box), so why doesn't this work on lpc1769?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527906#M696</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527907#M697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sat Jan 28 14:58:38 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: kayoda&lt;/STRONG&gt;&lt;BR /&gt;Are you kidding?&lt;BR /&gt;What do you think is (uint8_t)256 = (uint8_t)0x100 ?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't understand... what is it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh my god, you're right - I'm totally .... well not my day... it's 255 (max value for 8bit number) + 1, which is zero...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;damn it. Sorry...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;edit: no, I'm still stupid. Changing it to uint32_t (which is unsigned int) doesn't help at all, I still get 0 for sizeof(buffer).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527907#M697</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527908#M698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sat Jan 28 15:16:23 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok. I will describe exactly what I'm doing because I going crazy here &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in 1 place I call this this function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
bytes = UARTReceive((LPC_UART_TypeDef*)LPC_UART0, buffer, (uint32_t)sizeof(buffer));
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;The function is defined as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint32_t buflen);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;When I put a breakpoint in the first line of this function and read the value of buflen - it's zero (0). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Even if I pass 256 and not sizeof - it's still zero!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527908#M698</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527909#M699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ex-kayoda on Sat Jan 28 16:06:36 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: dragilla&lt;/STRONG&gt;&lt;BR /&gt;Why is it called int if it's a char? :(&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Google is your friend:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://en.wikipedia.org/wiki/C_data_types&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Fixed width integer types:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The[B][COLOR=Red] C99 standard[/COLOR][/B] includes definitions of several new integer types to enhance the portability of programs[2]...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527909#M699</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527910#M700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by atomicdog on Sat Jan 28 19:37:34 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;When I put a breakpoint in the first line of this function and read the value of buflen - it's zero (0). &lt;BR /&gt;Even if I pass 256 and not sizeof - it's still zero! &lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Have you stepped through the code in the function? What does the code look like in the function? what optimization setting are you using?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527910#M700</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527911#M701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Rob65 on Sat Jan 28 23:57:06 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hm,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think we start to need a moderator in this forum...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why start swearing ???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Things like shit, wft or o my god do not belong in this forum so I kindly ask you to refrain from using these things in the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use sizeof a lot and it always works for me - even om my lpc1769.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And what did you think ???&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;........ I just got to the definition of uint8_t - it's&lt;BR /&gt;typedef unsigned char uint8_t;&lt;BR /&gt;&lt;BR /&gt;Why is it called int if it's a char? :(&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What else is a data type than a representation of some bytes or words in memory :eek:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use uit8_t .. uint64_t on different platform. The nice thing is that I now have one datatype specifying the exact amount of bits. While on the ARM an unsigned int may be 32 bits, on some other processors I used, an (unsigned) int was 64 bits and on yet another one 16 bits.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527911#M701</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527912#M702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sun Jan 29 01:16:50 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Rob, you're of course right, sorry for that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: atomicdog&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Have you stepped through the code in the function? What does the code look like in the function? what optimization setting are you using?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use no optimization (0). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The receive function is declared as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
uint32_t UARTReceive(LPC_UART_TypeDef *UARTPort, uint8_t *rxbuf, uint32_t buflen)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t* data = (uint8_t *) rxbuf; &amp;lt;--- BREAKPOINT HERE SHOWS 0 FOR buflen !
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t temp_tail;
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t prev = 99;
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t bytes = 0;

/* Temporarily lock out UART receive interrupts during this
&amp;nbsp;&amp;nbsp; read so the UART receive interrupt won't cause problems
&amp;nbsp;&amp;nbsp; with the index values */
UART_IntConfig(UARTPort, UART_INTCFG_RBR, DISABLE);

// check for cr lf (\r\n) in the rb buffer. if found -&amp;gt; copy all from
// the beginning to the \r\n and move everything after to the beginning.
temp_tail = rb.rx_tail;
while(!(__BUF_IS_EMPTY(rb.rx_head, temp_tail)) &amp;amp;&amp;amp; bytes &amp;lt; UART_RING_BUFSIZE) {

*data = rb.rx[temp_tail];
data ++;
bytes ++;

if(prev == '\r' &amp;amp;&amp;amp; rb.rx[temp_tail] == '\n') { // gotcha

// set rb.rx_tail
__BUF_INCR(temp_tail);
rb.rx_tail = temp_tail;

*data = '\0';

// enable interrupt
UART_IntConfig(UARTPort, UART_INTCFG_RBR, ENABLE);

// return bytes to say we have a full line
return bytes;
}
prev = rb.rx[temp_tail];
__BUF_INCR(temp_tail);
}

/* Re-enable UART interrupts */
UART_IntConfig(UARTPort, UART_INTCFG_RBR, ENABLE);

// if we are here it means a whole line was not found -&amp;gt; return 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I call the function like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
bytes = UARTReceive((LPC_UART_TypeDef*)LPC_UART0, buffer, (uint32_t)256);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ps: the sizeof works. My problem was trying to fit 256 into an 8-bit variable.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527912#M702</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527913#M703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragilla on Sun Jan 29 01:34:39 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok. I've found the reason for bad readouts. The function had two definitions. One in the file where it was called and the second in the file where it was declared. I only changed it in one place (the place of declaration), so it was still called with uint8_t.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527913#M703</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: sizeof problem</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527914#M704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Rob65 on Sun Jan 29 05:55:37 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: dragilla&lt;/STRONG&gt;&lt;BR /&gt;Rob, you're of course right, sorry for that.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems like we both had a bad week.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tend to skip to this forum whenever I'm stuck in some kind of problem and need a break - I am trying to create a PC program that interfaces with my LPC solution and had a lot of problems getting the GUI to work in Qt - almost bit my tongue of twice this weekend :eek: - I'm just not experienced enough in C++ yet&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;ps: the sizeof works. My problem was trying to fit 256 into an 8-bit variable.&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Use a bigger hammer :D&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;The function had two definitions. One in the file where it was called and the second in the file where it was declared. &lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Been there, done that ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I never ever (well ...) do this anymore. I make only one declaration in a header file that gets included everywhere. The compile will then perform the type casting and warn me if I'm doing anything funny.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My goal is to have no warnings at all in my code. I have learned that a lot of the warnings are actually errors - or exceptions that should be solved using some type casting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At work we have even set the compiler to handle all warnings as errors (i.e. no executable gets generated).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:52:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/sizeof-problem/m-p/527914#M704</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:52:46Z</dc:date>
    </item>
  </channel>
</rss>

