Error compiling Neopixel with PRODUCT_ID and PRODUCT_VERSION

I’m getting an error when I try to verify an app using Neopixel with PRODUCT_ID and PRODUCT_VERSION (part of the beta organization dashboard).

Here’s example code that will throw the error:

// This #include statement was automatically added by the Spark IDE.
#include "neopixel/neopixel.h"

PRODUCT_ID(1);
PRODUCT_VERSION(1);

And the full error:

In file included from ../inc/spark_wiring.h:29:0,
                 from ../inc/application.h:29,
                 from neopixel/neopixel.h:53,
                 from neopixel/neopixel.cpp:50:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^
In file included from neopixel/neopixel.cpp:50:0:
neopixel/neopixel.h: In constructor 'Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t, uint8_t, uint8_t)':
neopixel/neopixel.h:99:5: warning: 'Adafruit_NeoPixel::pixels' will be initialized after [-Wreorder]
    *pixels;        // Holds LED color values (3 bytes each)
     ^
neopixel/neopixel.h:95:5: warning:   'const uint8_t Adafruit_NeoPixel::type' [-Wreorder]
     type;          // Pixel type flag (400 vs 800 KHz)
     ^
neopixel/neopixel.cpp:65:1: warning:   when initialized here [-Wreorder]
 Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n, uint8_t p, uint8_t t) : 
 ^
In file included from ../inc/spark_wiring.h:29:0,
                 from ../inc/application.h:29,
                 from neopixel_test.cpp:2:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^
neopixel_test.cpp:4:11: error: expected constructor, destructor, or type conversion before '(' token
 #line 1 
           ^

neopixel_test.cpp:5:16: error: expected constructor, destructor, or type conversion before '(' token
 
                ^

make: *** [neopixel_test.o] Error 1

I thought it was a define statement, but would love to hear from someone who knows for sure.

Any thoughts on where I should start debugging @BDub?

These are fixed in v0.4.4, which we are having a release meeting about shortly :wink:

Hey @chap,

We are corresponding privately but wanted to put the answer here as well to ensure it is publicly visible. I was able to dig into your issue a bit more, and I was able to replicate the error that you were having. One important thing to keep in mind when compiling in the IDE is that the compile service will compile a binary for the device you currently have selected to flash to. When I have a Core selected, I am able to reproduce this error. When I have a Photon selected, the macros compile just fine. This should be working for both types of devices, but there may be an issue with the Core firmware compile service.

In your devices pane, can you select a Photon to flash to like below?

I notice that you’ve created a product that is built for the photon. If you already have a device that you added to the product, it will show up as an “Other” category in this pane, kind of like this:

Selecting a device like this should also work.

Does this make sense? Really hope we can get this resolved for you quickly.

Jeff

Thanks!

Everything seems to be working for me now.

Hi All,

I’m having the same issue but I build the code for the Core. What is the solution in that case?

the product macros aren’t presently supported on the core. They will be available with the 0.4.5 release.
Cheers,
mat

Hi @mdma

Wondering if there’s a way to do this now. I’m trying to set PRODUCT_ID and PRODUCT_VERSION for my core device through the web IDE (build.particle.io).

Cheers,

Arian

Be sure you’re targeting at least version 0.4.5 of firmware for your device. Then you can use the PRODUCT_ID and PRODUCT_VERSION macros.

https://docs.particle.io/reference/firmware/photon/#product_id-