<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How can one use MyMessage class in library?]]></title><description><![CDATA[<p dir="auto">How can one use MyMessage class in library?</p>
<p dir="auto">When I try to</p>
<pre><code>#include &lt;MySensors.h&gt;
</code></pre>
<p dir="auto">in my library code I get:<br />
Arduino/libraries/MySensors/MySensors.h:426:2: error: #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.</p>
<p dir="auto">without include I of course get:</p>
<p dir="auto">Button.h:13:5: error: 'MyMessage' does not name a type<br />
MyMessage msg;</p>
]]></description><link>https://forum.mysensors.org/topic/11005/how-can-one-use-mymessage-class-in-library</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 05:03:48 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/11005.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Mar 2020 16:13:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can one use MyMessage class in library? on Sun, 15 Mar 2020 11:03:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/matkor" aria-label="Profile: matkor">@<bdi>matkor</bdi></a> said in <a href="/post/104278">How can one use MyMessage class in library?</a>:</p>
<blockquote>
<p dir="auto">Switching both clashing functions ( wakeUp1(), wakeUp2() )  to static functions seems to fix linking for me.</p>
</blockquote>
<p dir="auto">This sees to be deadend as there come more function name clashes, and i suspect linking problems come from magic done by arduino IDE.</p>
<p dir="auto">Current hack for me is include in arduino sketch my lib headers after including MySensors:</p>
<pre><code>#include &lt;MySensors.h&gt;
#include &lt;MyLib.h&gt;
</code></pre>
<p dir="auto">and than inside library use only:</p>
<pre><code>#include &lt;core/MySensorsCore.h&gt;
</code></pre>
<p dir="auto">not sure if its right solution, if one has any better please share.</p>
]]></description><link>https://forum.mysensors.org/post/104332</link><guid isPermaLink="true">https://forum.mysensors.org/post/104332</guid><dc:creator><![CDATA[matkor]]></dc:creator><pubDate>Sun, 15 Mar 2020 11:03:36 GMT</pubDate></item><item><title><![CDATA[Reply to How can one use MyMessage class in library? on Mon, 09 Mar 2020 09:18:21 GMT]]></title><description><![CDATA[<p dir="auto">Switching both clashing functions ( wakeUp1(), wakeUp2() )  to static functions seems to fix linking for me.</p>
<pre><code>diff --git a/hal/architecture/AVR/MyHwAVR.cpp b/hal/architecture/AVR/MyHwAVR.cpp
index 5a17b063..a018ab35 100644
--- a/hal/architecture/AVR/MyHwAVR.cpp
+++ b/hal/architecture/AVR/MyHwAVR.cpp
@@ -41,7 +41,7 @@ volatile uint8_t _wakeUp2Interrupt  =
 
 static uint32_t sleepRemainingMs = 0ul;
 
-void wakeUp1(void)
+void static wakeUp1(void)
 {
        // Disable sleep. When an interrupt occurs after attachInterrupt,
        // but before sleeping the CPU would not wake up.
@@ -53,7 +53,7 @@ void wakeUp1(void)
                _wokeUpByInterrupt = _wakeUp1Interrupt;
        }
 }
-void wakeUp2(void)
+void static wakeUp2(void)
 {
        sleep_disable();
        detachInterrupt(_wakeUp2Interrupt);
diff --git a/hal/architecture/NRF5/MyHwNRF5.cpp b/hal/architecture/NRF5/MyHwNRF5.cpp
index d91a0438..f083a17c 100644
--- a/hal/architecture/NRF5/MyHwNRF5.cpp
+++ b/hal/architecture/NRF5/MyHwNRF5.cpp
@@ -28,11 +28,11 @@ volatile uint8_t _wakeUp1Interrupt =
 volatile uint8_t _wakeUp2Interrupt =
     INVALID_INTERRUPT_NUM; // Interrupt number for wakeUp2-callback.
 
-void wakeUp1(void) // place to send the interrupts
+void static wakeUp1(void) // place to send the interrupts
 {
        _wokeUpByInterrupt = _wakeUp1Interrupt;
 }
-void wakeUp2(void) // place to send the second interrupts
+void static wakeUp2(void) // place to send the second interrupts
 {
        _wokeUpByInterrupt = _wakeUp2Interrupt;
 }
</code></pre>
]]></description><link>https://forum.mysensors.org/post/104278</link><guid isPermaLink="true">https://forum.mysensors.org/post/104278</guid><dc:creator><![CDATA[matkor]]></dc:creator><pubDate>Mon, 09 Mar 2020 09:18:21 GMT</pubDate></item><item><title><![CDATA[Reply to How can one use MyMessage class in library? on Sun, 08 Mar 2020 21:25:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tekka" aria-label="Profile: tekka">@<bdi>tekka</bdi></a> said in <a href="/post/104265">How can one use MyMessage class in library?</a>:</p>
<blockquote>
<p dir="auto">#define MY_CORE_ONLY</p>
</blockquote>
<p dir="auto">It solved compiiation errors, but now I have link errors(I have many <em>.cpp/</em>.h files in my lib):</p>
<pre><code>/tmp/arduino_build_899057/libraries/MyLib/Foo.cpp.o (symbol from plugin): In function `wakeUp1()':(.text+0x0): multiple definition of `wakeUp1()'
</code></pre>
<p dir="auto">Seems same as <a href="https://forum.mysensors.org/topic/6084/including-mysensors-h-in-multiple-files">https://forum.mysensors.org/topic/6084/including-mysensors-h-in-multiple-files</a> .<br />
I tried:</p>
<pre><code>#include &lt;core/MySensorsCore.h&gt;
</code></pre>
<p dir="auto">but it fails:</p>
<pre><code>Alternatives for core/MyMessage.h: []In file included from mytest.ino:13:0:
ResolveLibrary(core/MyMessage.h)
  -&gt; candidates: []

MyLib/MyLib.h:10:10: fatal error: core/MyMessage.h: No such file or directory
 #include &lt;core/MyMessage.h&gt;
          ^~~~~~~~~~~~~~~~~~
compilation terminated.

</code></pre>
]]></description><link>https://forum.mysensors.org/post/104267</link><guid isPermaLink="true">https://forum.mysensors.org/post/104267</guid><dc:creator><![CDATA[matkor]]></dc:creator><pubDate>Sun, 08 Mar 2020 21:25:05 GMT</pubDate></item><item><title><![CDATA[Reply to How can one use MyMessage class in library? on Sun, 08 Mar 2020 16:21:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/matkor" aria-label="Profile: matkor">@<bdi>matkor</bdi></a> like that:</p>
<pre><code>#define MY_CORE_ONLY
#include &lt;MySensors.h&gt;
MyMessage MyVar;

void setup() {}
void loop() {}
</code></pre>
]]></description><link>https://forum.mysensors.org/post/104265</link><guid isPermaLink="true">https://forum.mysensors.org/post/104265</guid><dc:creator><![CDATA[tekka]]></dc:creator><pubDate>Sun, 08 Mar 2020 16:21:55 GMT</pubDate></item></channel></rss>