<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Error adding USBD project</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44308/error-adding-usbd-project</link><description>I want to add USBD function in other projects, but there is an error:“..\..\..\..\..\..\components\libraries\usbd\class\hid\generic\app_usbd_hid_generic.c(257): error: #20: identifier &amp;quot;ret&amp;quot; is undefined” 
 
 
 
 
 
 How to modify？ Thank you all 
 
 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Mar 2019 08:59:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44308/error-adding-usbd-project" /><item><title>RE: Error adding USBD project</title><link>https://devzone.nordicsemi.com/thread/173888?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2019 08:59:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:412ae5d4-b9e8-4a1e-9db2-895f2e7c9134</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="73639" url="~/f/nordic-q-a/44308/error-adding-usbd-project/173859"]But the original official example is normal here?[/quote]
&lt;p&gt;Yes,&amp;nbsp;&lt;span&gt;that is because the&amp;nbsp;&lt;span&gt;CRITICAL_REGION macros is only using &amp;quot;{&amp;quot; and a &amp;quot;}&amp;quot; character when we have&amp;nbsp;SOFTDEVICE_PRESENT defined.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;So this is a bug in&amp;nbsp;app_usbd_hid_generic.c, app_usbd_hid_generic_idle_report_set() function, I will report it internally.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error adding USBD project</title><link>https://devzone.nordicsemi.com/thread/173859?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2019 01:30:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b08714c1-5a15-4460-983d-13cd8aaea911</guid><dc:creator>shenwrt</dc:creator><description>&lt;p&gt;OK, thank you. But the original official example is normal here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error adding USBD project</title><link>https://devzone.nordicsemi.com/thread/173814?ContentTypeID=1</link><pubDate>Sat, 02 Mar 2019 12:39:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b1befea-8be6-480d-9575-f89f680b641d</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Those CRITICAL_REGION macros contain a &amp;quot;{&amp;quot; and a &amp;quot;}&amp;quot; character each, thus &amp;quot;ret&amp;quot; is outside scope at the return statement.&lt;/p&gt;
&lt;p&gt;Fix is really simple, just declare it early:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
ret_code_t ret;

CRITICAL_REGION_ENTER();

ret = app_usbd_ep_transfer(ep_addr, &amp;amp;transfer);
if (ret == NRF_SUCCESS)
{
app_usbd_hid_state_flag_set(&amp;amp;p_generic_ctx-&amp;gt;hid_ctx,
APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS);
}

CRITICAL_REGION_EXIT();

return ret;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error adding USBD project</title><link>https://devzone.nordicsemi.com/thread/173784?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 21:00:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:429f8064-5370-43a5-afcd-522a6f9d2a78</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;how to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7343._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error adding USBD project</title><link>https://devzone.nordicsemi.com/thread/173778?ContentTypeID=1</link><pubDate>Fri, 01 Mar 2019 19:54:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f233b0ec-b139-4488-9b4b-5582207fd4fb</guid><dc:creator>shenwrt</dc:creator><description>&lt;ul&gt;
&lt;li&gt;
&lt;p class="src"&gt;Normal after deleting critical Macro：&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;// CRITICAL_REGION_ENTER();&lt;br /&gt; ret_code_t ret = app_usbd_ep_transfer(ep_addr, &amp;amp;transfer);&lt;br /&gt; if (ret == NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; app_usbd_hid_state_flag_set(&amp;amp;p_generic_ctx-&amp;gt;hid_ctx,&lt;br /&gt; APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS);&lt;br /&gt; }&lt;br /&gt;// CRITICAL_REGION_EXIT();&lt;/p&gt;
&lt;p&gt;return ret;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>