<?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>Macro compilation in C++</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28574/macro-compilation-in-c</link><description>I am porting a C++ project that was using version 6 of the SDK to version 14.2 (big leap, I know). I want to use all the new bells and whistles from the new SDK that makes life easier, but I am getting some errors when wanting to emulate what is being</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Dec 2017 06:40:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28574/macro-compilation-in-c" /><item><title>RE: Macro compilation in C++</title><link>https://devzone.nordicsemi.com/thread/113218?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 06:40:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a227c2c3-5bef-4ff3-b3ab-c60c52c69d33</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;You are right, I use GNU C++11 flag not the ISO C++ 11.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Macro compilation in C++</title><link>https://devzone.nordicsemi.com/thread/113217?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 06:24:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25352c20-4cf2-49b2-8cd0-48f89bc5f6ae</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;This is not legal syntax in C++11 (&lt;a href="http://en.cppreference.com/w/cpp/language/aggregate_initialization"&gt;C++20 supports it&lt;/a&gt;). From some &lt;a href="https://stackoverflow.com/a/14101575"&gt;answers online&lt;/a&gt;, it can look like GCC&amp;#39;s C++ frontend will support this syntax for older standards as well, but this does not mean every compiler will support it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Macro compilation in C++</title><link>https://devzone.nordicsemi.com/thread/113216?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 00:17:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d2ebdb5-7504-4a6c-bb33-62e7da0bc61d</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;I don&amp;#39;t have any issue compiling that in C++ see &lt;a href="https://github.com/I-SYST/EHAL/blob/master/ARM/Nordic/src/ble_app_nrf52.cpp"&gt;EHAL&lt;/a&gt; code.&lt;br /&gt;
Verify that you have C++ 11 setting for the compiler.
PS. I am using GCC 6.2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Macro compilation in C++</title><link>https://devzone.nordicsemi.com/thread/113219?ContentTypeID=1</link><pubDate>Tue, 19 Dec 2017 21:35:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60ca18d8-81ad-4015-a16c-e67e34a059d2</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately, I do not see any way to use the macros with C++ as-is. These macros evalueate down to assignment of variables to members of a struct, like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_SECTION_SET_ITEM_REGISTER(sdh_soc_observers, _prio, static nrf_sdh_soc_evt_observer_t _name) =  \
{                                                                                                   \
    .handler   = _handler,                                                                          \
    .p_context = _context                                                                           \
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This format does not seem to be supported by C++ (specifying the name of the member that is being assigned). Instead, you will have to use this format:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_SECTION_SET_ITEM_REGISTER(sdh_soc_observers, _prio, static nrf_sdh_soc_evt_observer_t _name) =  \
{                                                                                                   \
    _handler,                                                                          \
    _context                                                                           \
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that this format is not as safe, as it will fail if you mess up the order of the assignments. I will report this issue internally, but I cannot guarantee that it will be fixed/changed. Our SDK is written to support C, and some of the coding methods is not well supported by C++.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>