<?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>LPC MicrocontrollersのトピックUART ROM example doesn't compile under C++ [SOLVED]</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-ROM-example-doesn-t-compile-under-C-SOLVED/m-p/513191#M50</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Tue Dec 23 20:01:13 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi everyone&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attempting to compile the "periph_uart_rom_polling" fails under C++. The example (as is) compiles ok under C. Nevertheless when I ported the code to a project in C++ then it fails to compile because of the "-fpermissive" flag.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;../src/my_driver.cpp:137:89: error: invalid conversion from 'UART_HANDLE_T {aka void*}' to 'void**' [-fpermissive]&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me post a striped version of the code so that we can focus in the issue:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/* UART handle and memory for ROM API */
static UART_HANDLE_T *uartHandle;

/* Use a buffer size larger than the expected return value of uart_get_mem_size() for the static UART handle type */
static uint32_t uartHandleMEM[0x10];

/* Setup UART handle and parameters */
static void setupUART()
{
uint32_t errCode;

/* 115.2KBPS, 8N1, ASYNC mode, no errors, clock filled in later */
UART_CONFIG_T cfg = {
0,/* U_PCLK frequency in Hz */
115200,/* Baud Rate in Hz */
1,/* 8N1 */
0,/* Asynchronous Mode */
NO_ERR_EN/* Enable No Errors */
};

/* Initialize UART0 */
Chip_UART_Init(LPC_USART0);

Chip_Clock_SetUARTFRGDivider(1);

/* Perform a sanity check on the storage allocation */
if (LPC_UARTD_API-&amp;gt;uart_get_mem_size() &amp;gt; sizeof(uartHandleMEM)) {
/* Example only: this should never happen and probably isn't needed for most UART code. */
errorUART();
}

/* Setup the UART handle */
uartHandle = LPC_UARTD_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, (uint8_t *) &amp;amp;uartHandleMEM); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;lt;---HERE IS THE ORIGINAL ERROR ...

//uartHandle = LPC_UARTD_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, (uint8_t *) uartHandleMEM); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // SO, FOLLOWING THE LOGIC, I TRIED THESE

//uartHandle = LPC_UARTD_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, uartHandleMEM); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // OTHER TWO LINES, BUT THE ERROR STILL EXISTS

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (uartHandle == NULL) {
errorUART();
}

/* Need to tell UART ROM API function the current UART peripheral clock speed */
cfg.sys_clk_in_hz = Chip_Clock_GetSystemClockRate();

/* Initialize the UART with the configuration parameters */
errCode = LPC_UARTD_API-&amp;gt;uart_init(uartHandle, &amp;amp;cfg);
if (errCode != LPC_OK) {
/* Some type of error handling here */
errorUART();
}
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As the code shows, the uart_setup() callback is expecting, in the second argument, a pointer to uint_8, and in my two attempts I've sent what the callback expects, so I don't understand why the error reports:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;error: invalid conversion from 'UART_HANDLE_T {aka void*}' to 'void**' [-fpermissive]&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe I'm overwatching something, but so far I cannot see any pointer to pointer. Besides, instead of&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;static uint32_t uartHandleMEM[0x10];&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've also used:&lt;/SPAN&gt;&lt;BR /&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 uartHandleMEM[sizeof(uint32_t) * 16];&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Right now I run out of ideas, so any help is welcomed. Thank you in advanced!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:04:03 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:04:03Z</dc:date>
    <item>
      <title>UART ROM example doesn't compile under C++ [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-ROM-example-doesn-t-compile-under-C-SOLVED/m-p/513191#M50</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Tue Dec 23 20:01:13 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi everyone&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attempting to compile the "periph_uart_rom_polling" fails under C++. The example (as is) compiles ok under C. Nevertheless when I ported the code to a project in C++ then it fails to compile because of the "-fpermissive" flag.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;../src/my_driver.cpp:137:89: error: invalid conversion from 'UART_HANDLE_T {aka void*}' to 'void**' [-fpermissive]&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me post a striped version of the code so that we can focus in the issue:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/* UART handle and memory for ROM API */
static UART_HANDLE_T *uartHandle;

/* Use a buffer size larger than the expected return value of uart_get_mem_size() for the static UART handle type */
static uint32_t uartHandleMEM[0x10];

/* Setup UART handle and parameters */
static void setupUART()
{
uint32_t errCode;

/* 115.2KBPS, 8N1, ASYNC mode, no errors, clock filled in later */
UART_CONFIG_T cfg = {
0,/* U_PCLK frequency in Hz */
115200,/* Baud Rate in Hz */
1,/* 8N1 */
0,/* Asynchronous Mode */
NO_ERR_EN/* Enable No Errors */
};

/* Initialize UART0 */
Chip_UART_Init(LPC_USART0);

Chip_Clock_SetUARTFRGDivider(1);

/* Perform a sanity check on the storage allocation */
if (LPC_UARTD_API-&amp;gt;uart_get_mem_size() &amp;gt; sizeof(uartHandleMEM)) {
/* Example only: this should never happen and probably isn't needed for most UART code. */
errorUART();
}

/* Setup the UART handle */
uartHandle = LPC_UARTD_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, (uint8_t *) &amp;amp;uartHandleMEM); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;lt;---HERE IS THE ORIGINAL ERROR ...

//uartHandle = LPC_UARTD_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, (uint8_t *) uartHandleMEM); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // SO, FOLLOWING THE LOGIC, I TRIED THESE

//uartHandle = LPC_UARTD_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, uartHandleMEM); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // OTHER TWO LINES, BUT THE ERROR STILL EXISTS

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (uartHandle == NULL) {
errorUART();
}

/* Need to tell UART ROM API function the current UART peripheral clock speed */
cfg.sys_clk_in_hz = Chip_Clock_GetSystemClockRate();

/* Initialize the UART with the configuration parameters */
errCode = LPC_UARTD_API-&amp;gt;uart_init(uartHandle, &amp;amp;cfg);
if (errCode != LPC_OK) {
/* Some type of error handling here */
errorUART();
}
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As the code shows, the uart_setup() callback is expecting, in the second argument, a pointer to uint_8, and in my two attempts I've sent what the callback expects, so I don't understand why the error reports:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;error: invalid conversion from 'UART_HANDLE_T {aka void*}' to 'void**' [-fpermissive]&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe I'm overwatching something, but so far I cannot see any pointer to pointer. Besides, instead of&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;static uint32_t uartHandleMEM[0x10];&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've also used:&lt;/SPAN&gt;&lt;BR /&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 uartHandleMEM[sizeof(uint32_t) * 16];&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Right now I run out of ideas, so any help is welcomed. Thank you in advanced!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:04:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UART-ROM-example-doesn-t-compile-under-C-SOLVED/m-p/513191#M50</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: UART ROM example doesn't compile under C++ [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-ROM-example-doesn-t-compile-under-C-SOLVED/m-p/513192#M51</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Tue Dec 23 20:54:08 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: fjrg76&lt;/STRONG&gt;&lt;BR /&gt;Right now I run out of ideas, so any help is welcomed.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
/* Setup the UART handle */
uartHandle = [color=#f00] (UART_HANDLE_T*) [/color]LPC_UARTD_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, (uint8_t *) &amp;amp;uartHandleMEM);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:04:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UART-ROM-example-doesn-t-compile-under-C-SOLVED/m-p/513192#M51</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: UART ROM example doesn't compile under C++ [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-ROM-example-doesn-t-compile-under-C-SOLVED/m-p/513193#M52</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Tue Dec 23 22:19:29 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Thank you R2D2&lt;/STRONG&gt;&lt;SPAN&gt;, your workaround solved the problem!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:04:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UART-ROM-example-doesn-t-compile-under-C-SOLVED/m-p/513193#M52</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:04:05Z</dc:date>
    </item>
  </channel>
</rss>

