Where are the data types declared in the Arduino source code. i.e. word, byte, char etc. I know you can easily cast a data type to another, but I want to know where in the source code these types are declared.
char is a primitive, and exists as a type in C.
word and byte however:
typedef unsigned int word; typedef uint8_t byte;
Thank you. Yes I saw that on the Arduino.h. Because the char data type comes with the C language does that mean they cant be altered at all in the Arduino code. I know this is a pointless exercise but just can I change char from signed to unsigned for example
if you want to work with an 'unsigned char' then you are free to declare one. 'char' is signed by default, same as short, int & long.
Its not quite pointless, they have slightly different semantics.
Yes but I am just wondering is there anywhere in the source code that the primitive data types can be modified. Or are these totally separate to the arduino source code
It is 'illegal' to redefine reserved words, however you can if you really want to (why not just use the type you want to change it to).
#define char int
However you'll have to manually include Arduino.h above it otherwise you'll get compile errors depending on what you change it to.
What I tried was:
typedef signed int char;
However this doesn't work, because it is throwing up an error multiple types in one declaration.
Is this just an exercise Kevin, or are you doing this as a workaround to shoehorn libs/code together?
If its the latter, share some details and we'll probably be able to help.
kevin306: Yes but I am just wondering is there anywhere in the source code that the primitive data types can be modified. Or are these totally separate to the arduino source code
They are totally separate - they are part of the C++ compiler.
That is what I thought, the compiler interprets that. So nothing in the arduino source can modify this data type correct?
kevin306: That is what I thought, the compiler interprets that. So nothing in the arduino source can modify this data type correct?
What are you getting at, exactly? Do you want to redefine for to be the same as while? Please state what the real problem is.
You think your problem, whatever it is, will be solved if you can change data types?
Char can be signed or unsigned. All I'm saying is I want it to behave always as unsigned and not signed. And I'm just asking can I modify this in the arduino source like word, byte and boolean can be modified. Or is this only handled by the compiler because it is a primitive data type. Just asking like nothing wrong with being inquisitive.
I found out the answer. Adding -funsigned-char when invoking the compiler. Sorry for my poor phrasing of the question.