Documentation parser is broken - *'s are stripped

After the last update to the documentation, the ‘*’-chars are being removed in several places it needs to be.

I had a whole class of students fail a project today with very mysterious error messages when trying to compile this example from the documentation: https://docs.particle.io/quickstart/photon/#the-buddy-system-publish-and-subscribe

If the person trying to do this tutorial tries to compile in the Web IDE, they will have absolutely no idea what is wrong since this IDE does not display all errors. When compiling from CLI, you’ll get the massive error output below and none of the errors listed will help beginners spot the problem.

Fixing the error is very simple, you just add back the star-chars to the example. Change this:

void myHandler(const char event, const char data)

into this:

void myHandler(const char *event, const char *data)

will make the example compile as it should on firmware 0.7.0. The error output points to an upcoming problem with 0.8.0 (not yet released) that will require an update to this example, but for now it’s better to just fix the Particle documentation-parser.

Processing  src/test.ino
make -C ../modules/photon/user-part all
make[1]: Entering directory '/firmware/modules/photon/user-part'
make -C ../../../user 
make[2]: Entering directory '/firmware/user'
Building cpp file: src/test.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-6-msrc/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=0.7.0 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../services/inc -I../communication/src -I../hal/inc -I../hal/shared -I../hal/src/photon -I../hal/src/stm32f2xx -I../hal/src/stm32 -I../hal/src/photon/api -I../hal/src/photon/include -I../hal/src/photon/wiced/security/BESL/host/WICED/ -I../hal/src/photon/wiced/security/BESL/include -I../hal/src/photon/wiced/security/BESL -I../hal/src/photon/wiced/security/BESL/crypto -I../hal/src/photon/wiced/WWD/include/ -I../hal/src/photon/wiced/platform/include/ -I../hal/src/photon/wiced/platform/GCC/ -I../hal/src/photon/wiced/security/BESL/supplicant/ -I../hal/src/photon/libraries/crypto -I../platform/shared/inc -I../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F2xx/CMSIS/Include -I../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../dynalib/inc -Isrc -I./libraries -I. -MD -MP -MF ../build/target/user/platform-6-msrc/test.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DSPARK_PLATFORM_NET=BCM9WCDUSI09 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=5 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,207 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++11 -c -o ../build/target/user/platform-6-msrc/test.o src/test.cpp
src/test.ino: In function 'void setup()':
src/test.ino:49:59: error: no matching function for call to 'CloudClass::subscribe(const char [25], void (&)(char, char))'
   Particle.subscribe("buddy_unique_event_name_", myHandler);
                                                           ^
In file included from ../wiring/inc/spark_wiring.h:47:0,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
../wiring/inc/spark_wiring_cloud.h:245:17: note: candidate: bool CloudClass::subscribe(const char*, EventHandler, Spark_Subscription_Scope_TypeDef)
     inline bool subscribe(const char *eventName, EventHandler handler, Spark_Subscription_Scope_TypeDef scope)
                 ^
../wiring/inc/spark_wiring_cloud.h:245:17: note:   candidate expects 3 arguments, 2 provided
../wiring/inc/spark_wiring_cloud.h:250:17: note: candidate: bool CloudClass::subscribe(const char*, EventHandler, const char*)
     inline bool subscribe(const char *eventName, EventHandler handler, const char *deviceID)
                 ^
../wiring/inc/spark_wiring_cloud.h:250:17: note:   candidate expects 3 arguments, 2 provided
../wiring/inc/spark_wiring_cloud.h:255:10: note: candidate: bool CloudClass::subscribe(const char*, wiring_event_handler_t, Spark_Subscription_Scope_TypeDef)
     bool subscribe(const char *eventName, wiring_event_handler_t handler, Spark_Subscription_Scope_TypeDef scope)
          ^
../wiring/inc/spark_wiring_cloud.h:255:10: note:   candidate expects 3 arguments, 2 provided
../wiring/inc/spark_wiring_cloud.h:260:10: note: candidate: bool CloudClass::subscribe(const char*, wiring_event_handler_t, const char*)
     bool subscribe(const char *eventName, wiring_event_handler_t handler, const char *deviceID)
          ^
../wiring/inc/spark_wiring_cloud.h:260:10: note:   candidate expects 3 arguments, 2 provided
../wiring/inc/spark_wiring_cloud.h:266:10: note: candidate: template<class T> bool CloudClass::subscribe(const char*, void (T::*)(const char*, const char*), T*, Spark_Subscription_Scope_TypeDef)
     bool subscribe(const char *eventName, void (T::*handler)(const char *, const char *), T *instance, Spark_Subscription_Scope_TypeDef scope)
          ^
../wiring/inc/spark_wiring_cloud.h:266:10: note:   template argument deduction/substitution failed:
src/test.ino:49:59: note:   mismatched types 'void (T::*)(const char*, const char*)' and 'void (*)(char, char)'
   Particle.subscribe("buddy_unique_event_name_", myHandler);
                                                           ^
In file included from ../wiring/inc/spark_wiring.h:47:0,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
../wiring/inc/spark_wiring_cloud.h:273:10: note: candidate: template<class T> bool CloudClass::subscribe(const char*, void (T::*)(const char*, const char*), T*, const char*)
     bool subscribe(const char *eventName, void (T::*handler)(const char *, const char *), T *instance, const char *deviceID)
          ^
../wiring/inc/spark_wiring_cloud.h:273:10: note:   template argument deduction/substitution failed:
src/test.ino:49:59: note:   mismatched types 'void (T::*)(const char*, const char*)' and 'void (*)(char, char)'
   Particle.subscribe("buddy_unique_event_name_", myHandler);
                                                           ^
In file included from ../wiring/inc/spark_wiring.h:47:0,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
../wiring/inc/spark_wiring_cloud.h:401:13: note: candidate: bool CloudClass::subscribe(const char*, EventHandler) <near match>
 inline bool CloudClass::subscribe(const char* name, EventHandler handler) {
             ^
../wiring/inc/spark_wiring_cloud.h:401:13: note:   conversion of argument 2 would be ill-formed:
src/test.ino:49:59: error: invalid conversion from 'void (*)(char, char)' to 'EventHandler {aka void (*)(const char*, const char*)}' [-fpermissive]
   Particle.subscribe("buddy_unique_event_name_", myHandler);
                                                           ^
In file included from ../wiring/inc/spark_wiring.h:47:0,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
../wiring/inc/spark_wiring_cloud.h:405:13: note: candidate: bool CloudClass::subscribe(const char*, wiring_event_handler_t)
 inline bool CloudClass::subscribe(const char* name, wiring_event_handler_t handler) {
             ^
../wiring/inc/spark_wiring_cloud.h:405:13: note:   no known conversion for argument 2 from 'void(char, char)' to 'wiring_event_handler_t {aka std::function<void(const char*, const char*)>}'
../wiring/inc/spark_wiring_cloud.h:283:10: note: candidate: template<class T> bool CloudClass::subscribe(const char*, void (T::*)(const char*, const char*), T*)
     bool subscribe(const char* name, void (T::*handler)(const char*, const char*), T* instance) PARTICLE_DEPRECATED_API_DEFAULT_SUBSCRIBE_SCOPE;
          ^
../wiring/inc/spark_wiring_cloud.h:283:10: note:   template argument deduction/substitution failed:
src/test.ino:49:59: note:   mismatched types 'void (T::*)(const char*, const char*)' and 'void (*)(char, char)'
   Particle.subscribe("buddy_unique_event_name_", myHandler);
                                                           ^
src/test.ino: In function 'void loop()':
src/test.ino:123:59: warning: 'particle::Future<bool> CloudClass::publish(const char*, const char*)' is deprecated: Beginning with 0.8.0 release, Particle.publish() will require event scope to be specified explicitly. Define PARTICLE_USING_DEPRECATED_API macro to avoid this warning. [-Wdeprecated-declarations]
         Particle.publish("your_unique_event_name","intact");
                                                           ^
In file included from ../wiring/inc/spark_wiring.h:47:0,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
../wiring/inc/spark_wiring_cloud.h:393:31: note: declared here
 inline particle::Future<bool> CloudClass::publish(const char* name, const char* data) {
                               ^
src/test.ino:136:59: warning: 'particle::Future<bool> CloudClass::publish(const char*, const char*)' is deprecated: Beginning with 0.8.0 release, Particle.publish() will require event scope to be specified explicitly. Define PARTICLE_USING_DEPRECATED_API macro to avoid this warning. [-Wdeprecated-declarations]
         Particle.publish("your_unique_event_name","broken");
                                                           ^
In file included from ../wiring/inc/spark_wiring.h:47:0,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
../wiring/inc/spark_wiring_cloud.h:393:31: note: declared here
 inline particle::Future<bool> CloudClass::publish(const char* name, const char* data) {
                               ^
src/test.ino: In function 'void myHandler(char, char)':
src/test.ino:159:27: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   if (strcmp(data,"intact")==0) {
                           ^
In file included from /usr/local/gcc-arm-embedded/arm-none-eabi/include/string.h:10:0,
                 from ../services/inc/logging.h:121,
                 from ../services/inc/service_debug.h:34,
                 from ../services/inc/debug.h:1,
                 from ../wiring/inc/spark_wiring.h:36,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
/usr/local/gcc-arm-embedded/arm-none-eabi/include/string.h:28:6: note:   initializing argument 1 of 'int strcmp(const char*, const char*)'
 int  _EXFUN(strcmp,(const char *, const char *));
      ^
src/test.ino:163:32: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   else if (strcmp(data,"broken")==0) {
                                ^
In file included from /usr/local/gcc-arm-embedded/arm-none-eabi/include/string.h:10:0,
                 from ../services/inc/logging.h:121,
                 from ../services/inc/service_debug.h:34,
                 from ../services/inc/debug.h:1,
                 from ../wiring/inc/spark_wiring.h:36,
                 from ./inc/application.h:40,
                 from src/test.cpp:1:
/usr/local/gcc-arm-embedded/arm-none-eabi/include/string.h:28:6: note:   initializing argument 1 of 'int strcmp(const char*, const char*)'
 int  _EXFUN(strcmp,(const char *, const char *));
      ^
../build/module.mk:267: recipe for target '../build/target/user/platform-6-msrc/test.o' failed
make[2]: Leaving directory '/firmware/user'
make[2]: *** [../build/target/user/platform-6-msrc/test.o] Error 1
../../../build/recurse.mk:11: recipe for target 'user' failed
make[1]: Leaving directory '/firmware/modules/photon/user-part'
make[1]: *** [user] Error 2
../build/recurse.mk:11: recipe for target 'modules/photon/user-part' failed
make: *** [modules/photon/user-part] Error 2
4 Likes

Yup, that seems to be an issue, can you file it here

Seems to be confined to the Quickstart section, but there it seems to have swallowed all asterisks, even in block comments (/* ..... */)

The code examples in the quickstart pages are fixed.

4 Likes