Arduino Forum

Using Arduino => Programming Questions => Topic started by: barryjo on Feb 16, 2018, 05:33 pm

Title: Are Roll and Pitch keywords?
Post by: barryjo on Feb 16, 2018, 05:33 pm
In the following structure, in a basically very simple program,the variables Roll and Pitch are of a different color meaning I guess they are keywords. Is this correct? Why?

typedef struct {
  char Name[20] = "Hamil";
  int Thrust = 11;
  int Yaw = 22;
  int Roll = 12;
  int Pitch = 44;
  int Fmode = 19;
} Payload;
Title: Re: Are Roll and Pitch keywords?
Post by: Delta_G on Feb 16, 2018, 05:36 pm
In the Arduino IDE when a word turns orange it just means that some library writer included that word in their keywords.txt file.  It doesn't mean that the word actually doe anything.  It certainly doesn't mean that it is reserved.  It doesn't even mean that it is in a library that you are using in your code, just that it is in some library on your computer. 

It's  a pretty useless thing the coloring on the Arduino IDE.  There are IDE's where the context sensitive coloring works and actually tells you something.  On Arduino the colors of words are meaningless. 
Title: Re: Are Roll and Pitch keywords?
Post by: barryjo on Feb 16, 2018, 05:41 pm
In my case, the words Roll and Pitch are the same color as int, byte, and struct, a green color.
In my test,I am not including any libraries at all.

Thanks

Title: Re: Are Roll and Pitch keywords?
Post by: Delta_G on Feb 16, 2018, 05:42 pm
In my case, the words Roll and Pitch are the same color as int, byte, and struct, a green color.
In my test,I am not including any libraries at all.

Thanks


It still doesn't tell you anything about how those words are used. They're certainly not reserved keywords.  You should be fine to use them however you want in your code. 
Title: Re: Are Roll and Pitch keywords?
Post by: pert on Feb 16, 2018, 05:47 pm
In my case, the words Roll and Pitch are the same color as int, byte, and struct, a green color.
That just means that in the root folder of one of your installed libraries there is a file named keywords.txt that contains the following lines:
Code: [Select]
Roll LITERAL1
Pitch LITERAL1

In my test,I am not including any libraries at all.
As Delta_G said, the Arduino IDE just blindly colors all keywords for all installed libraries regardless of whether you are actually using that library in your sketch.