<?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>nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17249/nrf_svci-h-does-not-compile-with-gcc-sdk-12-1-0</link><description>I&amp;#39;m getting the following compilation error when trying to build the DFU bootloader example, using gcc 4.9.3 (4_9-2015q3) on Mac. 
 In file included from /Users/Eliot/dev/nRF5_SDK_12.1.0_0d23e2a/components/libraries/crypto/nrf_crypto.h:17:0,
 from dfu_req_handling</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Nov 2016 06:13:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17249/nrf_svci-h-does-not-compile-with-gcc-sdk-12-1-0" /><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66257?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2016 06:13:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22fca734-367b-4875-b951-8e73bf727eaf</guid><dc:creator>PekkaNikander</dc:creator><description>&lt;p&gt;@syntroniks: You seem to have encountered another bug.  Try the following.  It may or may not work.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;--- a/Nordic_SDK/nRF5_SDK_12.1.0_0d23e2a/components/libraries/svc/nrf_svc_function.h 
+++ b/Nordic_SDK/nRF5_SDK_12.1.0_0d23e2a/components/libraries/svc/nrf_svc_function.h
@@ -50,7 +50,7 @@ STATIC_ASSERT(sizeof(nrf_svc_func_reg_t) % 4 == 0);
  * @details     This macro places the variable in a section named &amp;quot;svc_data&amp;quot; that
             the SVC handler uses during regular operation.
  */
-#define SVC_REGISTER_FUNCTION(svc_var) NRF_SECTION_VARS_ADD(svc_data, svc_var)
+#define SVC_REGISTER_FUNCTION(svc_var) NRF_SECTION_VARS_REGISTER_VAR(svc_data, svc_var)
 
 
 #ifdef __cplusplus
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66256?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 21:57:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd920475-4fea-419c-b2ae-178884cdf00d</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;@PekkaNikander: in response to your comment.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;4&amp;gt; In file included from ../../../../../../components/libraries/crypto/nrf_crypto.h:17:0,
4&amp;gt;                  from C:/Work/nRF5_SDK_12.1.0_0d23e2a/examples/ble_peripheral/experimental_ble_app_buttonless_dfu/pca10040/s132/arm5_no_packs/../../../main.c:46:
4&amp;gt; ../../../../../../components/libraries/svc/nrf_svci.h:69:93: error: expected declaration specifiers or &amp;#39;...&amp;#39; before &amp;#39;)&amp;#39; token
4&amp;gt; ../../../../../../components/libraries/svc/nrf_svci.h:125:9: note: in expansion of macro &amp;#39;SVCI_DECL&amp;#39;
4&amp;gt; ../../../../../../components/libraries/svc/nrf_svci.h:146:70: note: in expansion of macro &amp;#39;SVCI_0&amp;#39;
4&amp;gt; ../../../../../../components/libraries/svc/nrf_svci.h:147:69: note: in expansion of macro &amp;#39;SVCI_IMPLI&amp;#39;
4&amp;gt; ../../../../../../components/libraries/svc/nrf_svci.h:148:57: note: in expansion of macro &amp;#39;SVCI_IMPL&amp;#39;
4&amp;gt; ../../../../../../components/libraries/crypto/nrf_crypto.h:105:1: note: in expansion of macro &amp;#39;SVCI&amp;#39;
4&amp;gt; ../../../../../../components/libraries/crypto/nrf_crypto.h: In function &amp;#39;nrf_crypto_init&amp;#39;:
4&amp;gt; ../../../../../../components/libraries/svc/nrf_svci.h:126:65: warning: implicit declaration of function &amp;#39;svci_nrf_crypto_init&amp;#39; [-Wimplicit-function-declaration]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After implementing the suggested workaround of &lt;code&gt;##__VA_ARGS__&lt;/code&gt;, I see&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;3&amp;gt; In file included from C:/Work/nRF5_SDK_12.1.0_0d23e2a/examples/ble_peripheral/experimental_ble_app_buttonless_dfu/pca10040/s132/arm5_no_packs/../../../../../../components/libraries/crypto/nrf_crypto_svc.c:13:0:
3&amp;gt; C:/Work/nRF5_SDK_12.1.0_0d23e2a/examples/ble_peripheral/experimental_ble_app_buttonless_dfu/pca10040/s132/arm5_no_packs/../../../../../../components/libraries/crypto/nrf_crypto_svc.c:23:23: error: expected &amp;#39;)&amp;#39; before &amp;#39;const&amp;#39;
3&amp;gt; ../../../../../../components/libraries/svc/nrf_svc_function.h:53:71: note: in definition of macro &amp;#39;SVC_REGISTER_FUNCTION&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66255?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 21:53:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e6b625d-24cc-4bdd-9b34-9a95f21e38e7</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;I have posted my response as an &amp;#39;answer&amp;#39; to this question because of its length.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66254?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 19:37:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1f36705-fdca-4380-b23f-17628424d3ed</guid><dc:creator>PekkaNikander</dc:creator><description>&lt;p&gt;What error message or messages do you get?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66253?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2016 19:18:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:098ce481-5f75-4780-be04-4fcc2eab0a9a</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;This solution does not work for me in Segger embedded studio. I can change the C standards (90, 99, 11), but can&amp;#39;t figure out how to compel the ide to remove those flags. In short: I did not have much luck with your patch.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66252?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 10:35:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b51396b6-0818-4af7-a853-c50d6baa7504</guid><dc:creator>PekkaNikander</dc:creator><description>&lt;p&gt;Note that this bug is still present in SDK 12.1.&lt;/p&gt;
&lt;p&gt;The root of this problem appears to be that the &lt;code&gt;__VA_ARGS__&lt;/code&gt; expansion has changed for C99 and C11.  In the old non-standard GCC days when &lt;code&gt;__VA_ARGS__&lt;/code&gt; expanded to empty, the preprocessor removed the preceding comma.  Not so any more with C99 and C11.  See
&lt;a href="http://stackoverflow.com/questions/5588855/standard-alternative-to-gccs-va-args-trick"&gt;stackoverflow.com/.../standard-alternative-to-gccs-va-args-trick&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With GCC, you can get rid of the syntax error is as simple as replacing &lt;code&gt;__VA_ARGS__&lt;/code&gt; with &lt;code&gt;##__VA_ARGS__&lt;/code&gt;.  However, that leads to a parameter type conflict with the expanded function declaration and definition.  Basically, the declaration lists &lt;code&gt;uint32_t svci_num&lt;/code&gt; as the first argument to the function, while the definition on the next lines does not.&lt;/p&gt;
&lt;p&gt;For example, the first definition of &lt;code&gt;nrf_crypto_init&lt;/code&gt; gets expanded from &lt;code&gt;SVCI_DECL&lt;/code&gt; [sic] to the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;__attribute__((naked, unused)) static uint32_t nrf_crypto_init(uint32_t NRF_CRYPTO_SVCI_INIT) ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, the following second definition expands to&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static inline uint32_t nrf_crypto_init(void) ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Apparently the mistake is that the first definition should actually define &lt;code&gt;svci_nrf_crypto_init&lt;/code&gt; instead of defining &lt;code&gt;nrf_crypto_init&lt;/code&gt; with a different signature.&lt;/p&gt;
&lt;p&gt;Here is a potential, mostly untested fix:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;--- a/Product_Configurations/SampoDFU/include/nrf_svci.h
+++ b/Product_Configurations/SampoDFU/include/nrf_svci.h
@@ -66,7 +66,7 @@ extern &amp;quot;C&amp;quot; {
                 _Pragma(&amp;quot;GCC diagnostic ignored \&amp;quot;-Wreturn-type\&amp;quot;&amp;quot;)     \
                 __attribute__((naked, unused))                          \
                 static return_type function_name(uint32_t svci_num,  \
-                                                                                 __VA_ARGS__)           \
+                                                 ##__VA_ARGS__)           \
                 {                                                       \
                         __asm __volatile (                                  \
                                 &amp;quot;mov r12, %1\n\t&amp;quot;                               \
@@ -122,23 +122,23 @@ extern &amp;quot;C&amp;quot; {
 #else
 
 #define SVCI_0(svci_num, return_type, function_name) \
-        SVCI_DECL(svci_num, return_type, function_name) \
+        SVCI_DECL(svci_num, return_type, svci_##function_name) \
         static __INLINE return_type function_name(void) {return svci_##function_name(svci_num);}
 
 #define SVCI_1(svci_num, return_type, function_name, p0t, p0n) \
-        SVCI_DECL(svci_num, return_type, function_name, p0t p0n) \
+        SVCI_DECL(svci_num, return_type, svci_##function_name, p0t p0n) \
         static __INLINE return_type function_name(p0t p0n) {return svci_##function_name(svci_num, p0n);}
 
 #define SVCI_2(svci_num, return_type, function_name, p0t, p0n, p1t, p1n) \
-        SVCI_DECL(svci_num, return_type, function_name, p0t p0n, p1t p1n) \
+        SVCI_DECL(svci_num, return_type, svci_##function_name, p0t p0n, p1t p1n) \
         static __INLINE return_type function_name(p0t p0n, p1t p1n) {return svci_##function_name(svci_num, p0n, p1n);}
 
 #define SVCI_3(svci_num, return_type, function_name, p0t, p0n, p1t, p1n, p2t, p2n) \
-        SVCI_DECL(svci_num, return_type, function_name, p0t p0n, p1t p1n, p2t p2n) \
+        SVCI_DECL(svci_num, return_type, svci_##function_name, p0t p0n, p1t p1n, p2t p2n) \
         static __INLINE return_type function_name(p0t p0n, p1t p1n, p2t p2n) {return svci_##function_name(svci_num, p0n, 
p1n, p2n);}
 
 #define SVCI_4(svci_num, return_type, function_name, p0t, p0n, p1t, p1n, p2t, p2n, p3t, p3n) \
-        SVCI_DECL(svci_num, return_type, function_name, p0t p0n, p1t p1n, p2t p2n, p3t p3n) \
+        SVCI_DECL(svci_num, return_type, svci_##function_name, p0t p0n, p1t p1n, p2t p2n, p3t p3n) \
         static __INLINE return_type function_name(p0t p0n, p1t p1n, p2t p2n, p3t p3n) {return svci_##function_name(svci_n
um, p0n, p1n, p2n, p3n);}
 
 #endif  // SVCALL_AS_NORMAL_FUNCTION
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is another tentative patch, to the other bug briefly discussed below.  It may or may not work.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;--- a/components/libraries/svc/nrf_svc_function.h 
+++ b/components/libraries/svc/nrf_svc_function.h
@@ -50,7 +50,7 @@ STATIC_ASSERT(sizeof(nrf_svc_func_reg_t) % 4 == 0);
  * @details     This macro places the variable in a section named &amp;quot;svc_data&amp;quot; that
             the SVC handler uses during regular operation.
  */
-#define SVC_REGISTER_FUNCTION(svc_var) NRF_SECTION_VARS_ADD(svc_data, svc_var)
+#define SVC_REGISTER_FUNCTION(svc_var) NRF_SECTION_VARS_REGISTER_VAR(svc_data, svc_var)
 
 
 #ifdef __cplusplus
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66251?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 07:52:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e298e8d3-942c-4deb-a3e3-77069db43beb</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Don&amp;#39;t use CFLAGS += -std=gnu99 if you want this to compile (thanks: Nguyen Hoan Hoang).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66250?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 12:22:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e28a5bcd-bbb9-4f90-8f43-177e7fd6f6a4</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;I believe that is the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66249?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 06:55:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d664773c-2533-4057-83d6-25077d7a3a5d</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;I have &amp;quot;CFLAGS += -std=gnu99&amp;quot; in my Makefiles, whereas the example DFU bootloader Makefiles seem to be missing a value for -std. Is that it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66248?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 04:25:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09b62a5a-063c-4ad7-8814-d1d893180fb4</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;what is your compiler settings for std ? C11 or C89 ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66245?ContentTypeID=1</link><pubDate>Mon, 24 Oct 2016 09:18:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed05bf1d-c058-4c25-a86f-9029a9226cbf</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I did not have any issues with compiling the secure bootloader using GCC 4.9.3 and the supplied Makefile, however im on Windows.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66247?ContentTypeID=1</link><pubDate>Sun, 23 Oct 2016 16:53:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ff8a0cd-9222-4892-89be-52022eb48737</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;But I&amp;#39;m not even using C++. Only C.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_svci.h does not compile with gcc, SDK 12.1.0</title><link>https://devzone.nordicsemi.com/thread/66246?ContentTypeID=1</link><pubDate>Sun, 23 Oct 2016 15:04:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36bc4d8a-2136-4f4c-8264-c3353359cbcb</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;The cast has to be uint16_t not uint8_t&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>