<?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>undefined reference to `vtable for __cxxabiv1::__si_class_type_info&amp;#39;</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42453/undefined-reference-to-vtable-for-__cxxabiv1-__si_class_type_info</link><description>Hey - I know there&amp;#39;s no official support for C++ on this platform, but are there any other intrepid devs out there making this work? 
 I was able to build, flash and run my app, but virtual functions were not working (virtual calls in the base class calling</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Jan 2019 02:04:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42453/undefined-reference-to-vtable-for-__cxxabiv1-__si_class_type_info" /><item><title>RE: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'</title><link>https://devzone.nordicsemi.com/thread/165847?ContentTypeID=1</link><pubDate>Wed, 16 Jan 2019 02:04:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ec03cc0-d2bc-4146-b19a-9e8a2efee67c</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;OK. I&amp;#39;ve got this sorted.&amp;nbsp; Turns out the two issues are unrelated:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Turning off RTTI support (which I don&amp;#39;t need) gets rid of the undefined reference.&lt;/p&gt;
&lt;p&gt;The vtable problem arose from the fact that I was trying to call the derived class method from within the base class constructor - i.e. before the derived class was fully constructed. Crap. I used to know that :-$&lt;/p&gt;
&lt;p&gt;Refactoring this flow out of the base ctor and calling it explicitly after the derived class was constructed resolved the issue.&lt;/p&gt;
&lt;p&gt;Apart from that, in case it helps anybody else, here are the other issues I faced and how they were resolved:&lt;/p&gt;
&lt;p&gt;1. C &amp;quot;_Static_assert&amp;quot; vs. C++ &amp;quot;static_assert&amp;quot;&lt;/p&gt;
&lt;p&gt;In app_util.h:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifdef __cplusplus
#define STATIC_ASSERT_SIMPLE(EXPR)      static_assert(EXPR, &amp;quot;unspecified message&amp;quot;)
#define STATIC_ASSERT_MSG(EXPR, MSG)    static_assert(EXPR, MSG)
#else
#define STATIC_ASSERT_SIMPLE(EXPR)      _Static_assert(EXPR, &amp;quot;unspecified message&amp;quot;)
#define STATIC_ASSERT_MSG(EXPR, MSG)    _Static_assert(EXPR, MSG)
#endif
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;2. Beyond that, there are many cases of C++ not liking this style of C struct initialization:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define GPIOTE_CONFIG_OUT_SIMPLE(init_high)                                                        \
    {                                                                                              \
        .init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW,    \
        .task_pin = false,                                                                         \
    }
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I solved this by adding a constructor to the struct:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifdef __cplusplus
typedef struct nrf_drv_gpiote_out_config_t_struct
{
    nrf_drv_gpiote_out_config_t_struct( nrf_gpiote_polarity_t polarity, nrf_gpiote_outinit_t state, bool isTaskPin )
        : action( polarity ), init_state( state ), task_pin( isTaskPin) {}
#else        
typedef struct 
{
#endif
    nrf_gpiote_polarity_t action;    /**&amp;lt; Configuration of the pin task. */
    nrf_gpiote_outinit_t  init_state; /**&amp;lt; Initial state of the output pin. */
    bool                  task_pin;  /**&amp;lt; True if the pin is controlled by a GPIOTE task. */
} nrf_drv_gpiote_out_config_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;and changing the define to a constructor call:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Macro for configuring a pin to use as output. GPIOTE is not used for the pin. */
#if defined __cplusplus
#define GPIOTE_CONFIG_OUT_SIMPLE(init_high) nrf_drv_gpiote_out_config_t_struct(                    \
											NRF_GPIOTE_POLARITY_LOTOHI,                            \
                                            init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \
                                            false )
#else
#define GPIOTE_CONFIG_OUT_SIMPLE(init_high)                                                        \
    {                                                                                              \
        .init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW,    \
        .task_pin = false,                                                                         \
    }
#endif&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>