Then I use #define I get error

Geting error:


…/the_user_app.cpp:3:1: error: ‘define’ does not name a type

btw. what does numbers ‘:3:1:’ means?

Code:

/**
  This is SOS Blink code.
Made by: Me
1Q2014
**/

     #define LED D7 
     #define dot 10
     int dash = dot * 3;                // If '#define dash 1500' code no not verifies. WHY?
     
     #define led1 A1                    // code verifies if this line do not exist. WHY?
     
    void setup() {
        pinMode (LED, OUTPUT);
        
      
        
        RGB.control(true);
        RGB.color(0, 0, 0);
    }
    
    void loop() {
        
        digitalWrite (LED,HIGH);         //start of 's'
        delay (dot);
        digitalWrite (LED,LOW);
        delay (dot);
        digitalWrite (LED,HIGH);
        delay (dot);
        digitalWrite (LED,LOW);
    delay (dot);
    digitalWrite (LED,HIGH);
    delay (dot);                      
    digitalWrite (LED,LOW);           
    delay (dash);
    digitalWrite (LED,HIGH);         //start of 'o'
    delay (dash);
    digitalWrite (LED,LOW);
    delay (dot);
    digitalWrite (LED,HIGH);
    delay (dash);
    digitalWrite (LED,LOW);
    delay (dot);
    digitalWrite (LED,HIGH);
    delay (dash);
    digitalWrite (LED,LOW);
    delay (dash);
    digitalWrite (LED,HIGH);         //start of 's'
    delay (dot);
    digitalWrite (LED,LOW);
    delay (dot);
    digitalWrite (LED,HIGH);
    delay (dot);
    digitalWrite (LED,LOW);
    delay (dot);
    digitalWrite (LED,HIGH);
    delay (dot);                      
    digitalWrite (LED,LOW);
    delay (7 * dot);  
}

But if I try this code on arduino, it verifies (I do change pin name). I use web API.

Hello @Xloras
You need to put all the definitions at the top before the variables.

#define LED D7 
#define dot 10
#define led1 A1   
         
int dash = dot * 3; 

The above sequence works.

Tnx for quick replay. It would nice if API point to row were error exist.

But why here same error message:

#define led1 A1
 #define LED D7 
 #define dot 10
 //int dash = dot * 3;                
 #define dash 1500

??
And what does those numbers (:3:1:) mean?

If you use #define, I noticed you also need to put at least one other kind of variable definition after them. Compiler bug.

the_user_app.cpp:3:1 means your user code, line 3, column 1. :smile:

Just popping in to say I added this compiler bug to our bug tracker, and I’ll update this thread when it’s fixed.

2 Likes

But it’s not were error was… so why it pointing here?

Our pre-processor adds a few lines of code at the top of yours, so the line numbers are not currently correct; that’s something that is on our backlog to fix.

Good to know Zach! I didn’t even notice I guess because most of the errors have info about what the error is and I zero in on those variables instead of the exact line number. Looks like it’s currently adding 5 to the line number.

It adds a line for each function prototype, so this addition is somewhat variable depending on how many functions you’ve got. Arduino’s pre-processor works similarly, they’ve got a fix for the line numbers, but we haven’t implemented one yet.

1 Like

Hey Guys,

Sorry about the delay. Just popping back in to say that this bug is fixed, please use #define’s with impunity! :slight_smile:

Thanks,
David

2 Likes