'uint8_t' does not name a type - Compile issue

I’m fairly new and I’m kind of stuck on this compile error that says “‘uint8_t’ does not name a type”.

I included particle-rf24.h to my .ino file as I’m testing nRF24l01 radio devices. The code was working few weeks ago and the same code gives me compiling errors now. I googled and searched in community forum and it was mentioned that application.h is not included and thus gives the error. I have included it in my code and i also see it included in the particle-rf24.cpp and yet get this error.

Below is my simple code, nothing fancy just to test the inclusion of particle-rf24.h file.

Code:

// This #include statement was automatically added by the Particle IDE.
#include <particle-rf24.h>

#include "application.h"
#include "stdarg.h"
#include "stdint.h"
#include "stddef.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"

//Code to test if photon works offline by triggerring D2 manually to set D7 automatically
int led7 = D7;
int led2 = D2;

void setup() {
    Serial.begin(9600);
//set the switch as input/output
    pinMode(led7, OUTPUT);
    pinMode(led2, INPUT);
}

void loop() {
    if (digitalRead(led2) == HIGH) {
        digitalWrite(led7, HIGH);
        Serial.println("Loop-D2 HIGH");
    }
    else{
        digitalWrite(led7, LOW);
        Serial.println("Loop-D2 LOW");
    }
    delay(3000);
  }

Errors:

lib/particle-rf24/src/particle-rf24.h:46:3: error: 'uint8_t' does not name a type
   uint8_t ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */
   ^

lib/particle-rf24/src/particle-rf24.h:47:3: error: 'uint8_t' does not name a type
   uint8_t csn_pin; /**< SPI Chip select */
   ^

i tried referring to github for source of particle-rf24.h files at https://github.com/stewarthou/Particle-RF24/tree/master/firmware and they seem to be matching with my included files.

Greatly appreciate any of your help and I’m fairly new so apologize if this is a silly error that I should have known. I’ll get better.

If this is an .ino file it might be due to the Wiring preprocessor or due to an other include failing to #include "Particle.h"

Update:
Just checked, and as expected particle-rf24.h fails to include the required definitions.

2 Likes

@ScruffR thank you very much for the response. Appreciate if you can let me know how to fix it. It doesn’t let me update the particle-rf24.h library that i included into my .ino.

@rajk, simply put #include "Particle.h"; before the #include <particle-rf24.h> line in your app.

@peekay123 thank you. i included it as you mentioned and it gives some errors within particle-rf24.cpp. Is it something to be changed in the community library?

Below is the errors i get:

In file included from lib/particle-rf24/src/particle-rf24.cpp:12:0:
lib/particle-rf24/src/particle-rf24_config.h:22:0: warning: "_BV" redefined [enabled by default]
     #define _BV(x) (1<<(x))
 ^
In file included from ./inc/application.h:92:0,
                 from lib/particle-rf24/src/particle-rf24.cpp:9:
../wiring/inc/spark_wiring_arduino.h:131:0: note: this is the location of the previous definition
 #define _BV(x)  (((uint32_t)1) << (x))
 ^
In file included from lib/particle-rf24/src/particle-rf24.cpp:12:0:
lib/particle-rf24/src/particle-rf24_config.h:25:0: warning: "pgm_read_word" redefined [enabled by default]
     #define pgm_read_word(p) (*(p))
 ^
In file included from ../wiring/inc/spark_wiring_arduino.h:35:0,
                 from ./inc/application.h:92,
                 from lib/particle-rf24/src/particle-rf24.cpp:9:
../wiring/inc/avr/pgmspace.h:99:0: note: this is the location of the previous definition
 #define pgm_read_word(addr) (*(const unsigned short *)(addr))
 ^
In file included from ../wiring/inc/spark_wiring_arduino.h:36:0,
                 from ./inc/application.h:92,
                 from lib/particle-rf24/src/particle-rf24.cpp:9:
../wiring/inc/spark_wiring_arduino_constants.h:32:21: error: expected unqualified-id before numeric constant
 #define SERIAL      0x0
                     ^

lib/particle-rf24/src/particle-rf24.cpp:19:6: note: in expansion of macro 'SERIAL'
 void SERIAL(const char *fmt, ... ){
      ^
lib/particle-rf24/src/particle-rf24.cpp: In member function 'void RF24::print_status(uint8_t)':
lib/particle-rf24/src/particle-rf24.cpp:235:11: error: expression cannot be used as a function
           );
           ^

lib/particle-rf24/src/particle-rf24.cpp: In member function 'void RF24::print_observe_tx(uint8_t)':
lib/particle-rf24/src/particle-rf24.cpp:246:11: error: expression cannot be used as a function
           );
           ^

Is it compiling fine with you. The code i compile is below

// This #include statement was automatically added by the Particle IDE.
#include "Particle.h"
#include <particle-rf24.h>

/*#include "application.h"
#include "stdarg.h"
#include "stdint.h"
#include "stddef.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"*/

//Code to test if photon works offline by triggerring D2 manually to set D7 automatically
int led7 = D7;
int led2 = D2;

void setup() {
    Serial.begin(9600);
//set the switch as input/output
    pinMode(led7, OUTPUT);
    pinMode(led2, INPUT);
}

void loop() {
    if (digitalRead(led2) == HIGH) {
        digitalWrite(led7, HIGH);
        Serial.println("Loop-D2 HIGH");
    }
    else{
        digitalWrite(led7, LOW);
        Serial.println("Loop-D2 LOW");
    }
    delay(3000);
  }

Thank you very much for your help and support.

You may want to target 0.6.0 instead of 0.6.1 for now.