# Compilation error with "deepsleep\_hal\_impl.h": It worked yesterday... but it doesn't today!?

**URL:** <https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162>\
**Category:** Troubleshooting\
**Created:** [October 2, 2015, 5:21pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162 "2015-10-02T17:21:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JIMtonic](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jimtonic/32/7391_2.png) [@JIMtonic](https://community.particle.io/u/JIMtonic)\
**Post date:** [October 2, 2015, 5:21pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/1 "2015-10-02T17:21:37Z")

</div>

Hey guys,

I’m getting a weird error when trying to compile a sketch in the Particle Build, that uses the MQTT and SparkJson libraries. I say weird, because yesterday I had four working sketches, and today any of them will compile ☹

The errors mention a library I’m never seen before, in a folder with the name of the microcontroller (STM32). Have a look at this…

```
../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:19: error: expected primary-expression before ' __attribute__'
 #define retained __attribute__ ((externally_visible, section(".retained_user")))
               ^

```

Any idea of what am I doing wrong?  
I checked the code tons of times, and I cannot find the error. Since the same code worked perfectly yesterday, I suspect that it might be an “external” issue… Or am I too dumb to realize of my error??? 😮

Thanks a lot for your help!  
Jaime

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [October 2, 2015, 5:58pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/2 "2015-10-02T17:58:13Z")

</div>

Hmm, there may be something going on with the Libraries because I can’t even compile the examples for the MQTT library or SparkJson library.

Can you provide a bare minimum example that generates this deepsleep\_hal\_impl.h error so we can look into it further? Thanks!

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [October 2, 2015, 6:17pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/3 "2015-10-02T18:17:00Z")

</div>

Hmmm…I wonder if those libraries use the `retained` keyword that we recently added?

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [October 2, 2015, 6:18pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/4 "2015-10-02T18:18:40Z")

</div>

please see [[Submission] MQTT Library and Sample](https://community.particle.io/t/submission-mqtt-library-and-sample/2111/66) for a fix.

Looks like the same issue?

---

<div class="post-metadata">

**Author:** ![JIMtonic](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jimtonic/32/7391_2.png) [@JIMtonic](https://community.particle.io/u/JIMtonic)\
**Post date:** [October 2, 2015, 6:19pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/5 "2015-10-02T18:19:18Z")

</div>

Wow, that was fast! Thanks for the quick reaction!  
You may find my sketch here: [https://drive.google.com/open?id=0B8MA2me0e\_7lbTJ6SlpYNkNveEU](https://drive.google.com/open?id=0B8MA2me0e_7lbTJ6SlpYNkNveEU)  
(Don’t forget to include the mentioned libraries, they’re already referenced in the code)

It’s just a simple application that sends data from two sensors to our cloud, so we can display it in two widgets later.

Here’s the entire error message…

```
In file included from ../hal/src/stm32f2xx/platform_headers.h:19:0,
                 from ./inc/application.h:32,
                 from MQTT.cpp:2:
../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:80: warning: 'externally_visible' attribute ignored [-Wattributes]
 #define retained __attribute__ ((externally_visible, section(".retained_user")))
                                                                                ^
MQTT.cpp:231:78: note: in expansion of macro 'retained'
 bool MQTT::publish(char* topic, uint8_t* payload, unsigned int plength, bool retained) {
                                                                              ^
../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:80: error: section attribute not allowed for '<anonymous>'
 #define retained __attribute__ ((externally_visible, section(".retained_user")))
                                                                                ^

MQTT.cpp:231:78: note: in expansion of macro 'retained'
 bool MQTT::publish(char* topic, uint8_t* payload, unsigned int plength, bool retained) {
                                                                              ^
MQTT.cpp: In member function 'bool MQTT::publish(char*, uint8_t*, unsigned int, bool)':
../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:19: error: expected primary-expression before ' __attribute__'
 #define retained __attribute__ ((externally_visible, section(".retained_user")))
                   ^

MQTT.cpp:241:13: note: in expansion of macro 'retained'
         if (retained) {
             ^
../hal/src/stm32f2xx/deepsleep_hal_impl.h:22:19: error: expected ')' before ' __attribute__'
 #define retained __attribute__ ((externally_visible, section(".retained_user")))
                   ^

MQTT.cpp:241:13: note: in expansion of macro 'retained'
         if (retained) {
             ^
make[1]: *** [../build/target/user/platform-6MQTT.o] Error 1
make: *** [user] Error 2

```

Thanks again!!!  
Jaime

PS. Sorry for my broken English! :\

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [October 2, 2015, 9:32pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/6 "2015-10-02T21:32:34Z")

</div>

Found the issue after the MQTT library now tries to compile. There is use of the word `retained` here:

`bool MQTT::publish(char* topic, uint8_t* payload, unsigned int plength, bool retained)`

which is a reserved keyword now. I just changed this to `kept` and it compiled. Obviously this is a bit of work to get the owner to update, but we can pretty easily submit a PR to their repo, which I have done here: [https://github.com/hirotakaster/MQTT/pull/9](https://github.com/hirotakaster/MQTT/pull/9) (If you have a github account and wanna go vote that up with a 👍 to increase exposure, please do 😉 )

---

<div class="post-metadata">

**Author:** ![JIMtonic](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jimtonic/32/7391_2.png) [@JIMtonic](https://community.particle.io/u/JIMtonic)\
**Post date:** [October 6, 2015, 9:32am UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/7 "2015-10-06T09:32:39Z")

</div>

Hey guys,

Sorry that I didn’t post some feedback earlier!

I’m still having problems, same error, no changes… any idea?  
Do the libraries need to be re-imported to Particle Build, or it reads them directly from GitHub?

Thanks a lot!  
Jaime

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [October 6, 2015, 10:01am UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/8 "2015-10-06T10:01:57Z")

</div>

As a workaround, if you don’t need the features in 0.4.6, you can revert to 0.4.5 in the IDE (click, “devices” then select your device and click the arrow, which will allow you to select a version.)

We will look at how to make this available as an opt-in so that the keyword doesn’t clash with existing code.

---

<div class="post-metadata">

**Author:** ![JIMtonic](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jimtonic/32/7391_2.png) [@JIMtonic](https://community.particle.io/u/JIMtonic)\
**Post date:** [October 6, 2015, 10:16am UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/9 "2015-10-06T10:16:23Z")

</div>

Awesome! It works again 😄  
Thanks a lot guys for the outstanding support!

Cheers,  
Jaime

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [October 6, 2015, 1:51pm UTC](https://community.particle.io/t/compilation-error-with-deepsleep-hal-impl-h-it-worked-yesterday-but-it-doesnt-today/16162/10 "2015-10-06T13:51:20Z")

</div>

> [@JIMtonic](#):
>
> I'm still having problems, same error, no changes... any idea?Do the libraries need to be re-imported to Particle Build, or it reads them directly from GitHub?

Yep, you need to remove the MQTT library from your app, and re-add it. As you can see here, the version bumped up from v0.2.5 to v0.2.6 as the author merged in my PR and re-imported the library: [https://build.particle.io/libs/560f2b631969eb8af1001727/tab/MQTT.cpp](https://build.particle.io/libs/560f2b631969eb8af1001727/tab/MQTT.cpp)

We have a task to search the Particle Libraries for the use of keyword `retained` so that we can find these issues before you encounter them hopefully! 😉
