<?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>Problems with BLE Mesh in a C++ project.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111198/problems-with-ble-mesh-in-a-c-project</link><description>I am using NCS Connect SDK version 2.6.0 
 I am trying to create an array of models and found a problem with using Zephry macros in C++ projects. My main.cpp is as below 
 
 
 BT_MESH_MODEL_CFG_SRV is defined in cfg_srv.h as 
 
 BT_MESH_MODEL_CNT_CB is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 01 Dec 2024 11:06:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111198/problems-with-ble-mesh-in-a-c-project" /><item><title>RE: Problems with BLE Mesh in a C++ project.</title><link>https://devzone.nordicsemi.com/thread/512856?ContentTypeID=1</link><pubDate>Sun, 01 Dec 2024 11:06:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24477cfd-ee16-4ed8-ba8f-1f8855136fa8</guid><dc:creator>AF1</dc:creator><description>&lt;p&gt;Thanks Jonathan&lt;br /&gt;Appreciate the response.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with BLE Mesh in a C++ project.</title><link>https://devzone.nordicsemi.com/thread/512090?ContentTypeID=1</link><pubDate>Tue, 26 Nov 2024 11:56:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0726ae76-6b59-4b4e-b27c-ab2cc7a7aa60</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Adding some extra comment for clearity:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Yes it is only supported in C. The suggestion for anyone who wants to use .cpp is to create a .c file where they instantiate composition data and expose pointer to that composition data through a header file. Then use this pointer in main.cpp. Or, simpler, move the entire mesh initialization to a .c file and call some init function from main.cpp.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with BLE Mesh in a C++ project.</title><link>https://devzone.nordicsemi.com/thread/485619?ContentTypeID=1</link><pubDate>Thu, 23 May 2024 11:40:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee403d9a-a5bc-428b-bc62-429339f43fe4</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;There has been a discussion about this before it seems, ref:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/57215#discussion_r1188749866"&gt;Bluetooth: Mesh: Make elements as const by LingaoM · Pull Request #57215 · zephyrproject-rtos/zephyr · GitHub&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;C++ syntax doesn&amp;#39;t support compound literals. It is possible to use GNU extension to enable it for C++ but it has different semantic (&lt;a title="https://gcc.gnu.org/onlinedocs/gcc/compound-literals.html" href="https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html" rel="noopener noreferrer" target="_blank"&gt;https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;As a consequence of mentioned above discussion the macros for C++ excluded : &lt;a title="https://github.com/zephyrproject-rtos/zephyr/pull/58311" href="https://github.com/zephyrproject-rtos/zephyr/pull/58311" rel="noopener noreferrer" target="_blank"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/58311&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It is not possible to use them for C++ as is. So either customize them for C++ or find out another approach.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;What could be proposed is:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span dir="ltr"&gt;We have already this issue as &lt;code&gt;keys&lt;/code&gt; and &lt;code&gt;groups&lt;/code&gt; are also initialized as compound literals. We propose surrounding this problematic defines with &lt;code&gt;#ifndef __cplusplus&lt;/code&gt;. C++ users can have a C-file (compiled with a C-compiler) with these macros to define variables, and access them in C++ code using &lt;code&gt;extern&lt;/code&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with BLE Mesh in a C++ project.</title><link>https://devzone.nordicsemi.com/thread/485538?ContentTypeID=1</link><pubDate>Thu, 23 May 2024 07:23:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e45c3f44-45d1-473e-bcda-28f1cad17e7a</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;No update as of now, will ping internally to try and rush things along&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with BLE Mesh in a C++ project.</title><link>https://devzone.nordicsemi.com/thread/485536?ContentTypeID=1</link><pubDate>Thu, 23 May 2024 07:13:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4380781f-20ec-4756-92db-48220ac7a384</guid><dc:creator>AF1</dc:creator><description>&lt;p&gt;Any updates on my ticket??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with BLE Mesh in a C++ project.</title><link>https://devzone.nordicsemi.com/thread/483522?ContentTypeID=1</link><pubDate>Wed, 15 May 2024 13:33:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3467ee1-cef5-45f0-b418-75e2091e9c8d</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;I have asked for this to be looked at infernally so that we can maybe try and find a more C++ friendly approached.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>