Hi, I am discovering the V-USB "library" for avr chips and this unions appears in usbdrv.h
How is
unsigned word;
a complete declaration? What type is this??
Hi, I am discovering the V-USB "library" for avr chips and this unions appears in usbdrv.h
How is
unsigned word;
a complete declaration? What type is this??
It is equivalent to unsigned int.
Sadly, exposure to Microsoft suggests "word" is a type itself.
word = uint16_t
(in Windows it is declared as "unsigned short").
If word is the type what is the variable's name?
What is happing is more obvious in the USB Driver discussion:
Communicating through Control endpoint 0
This is the most basic functionality of USB. Messages sent to control endpoints consist of 8 bytes structured setup data (each byte has a particular meaning) and a block of arbitrary length which is either received from the device (control-in) or sent to the device (control-out). Since the length can be zero, the
data block is optional. The 8 bytes setup data are described by the C type usbRequest_t which is declared in usbdrv.h:
Driver API - V-USB.pdf (140.5 KB)
word isn’t reserved in C.
#include <stdio.h>
int word;
int main()
{
word = 777;
printf("Hello World %d", word);
return 0;
}
a7
OK. I think what I and the OP are asking is that, to declare a variable it is given a type and a name. The unsigned keyword is a modifier of type, not a type in itself. What part of that do I have wrong.
If word is the name, what is the type?
If word is the type, what is the name?
If neither apply, why?
Also,
10 year-old project page for V-USB.
Note: V-USB is also used in Adafruit's Trinkets and DigiStump's DigiSpark boards
Just for fun run this:
unsigned test;
void setup() {
Serial.begin(115200);
Serial.println(sizeof(test));
}
void loop() {
}
I do not believe "unsigned" itself is a type. In this case, it should read:
unsigned int word;
or, MUCH better still:
uint16_t word;
In light of reply #13,
I see. So word is the name and type is whatever type the compiler assigns. The compiler just assumes an int (2 bytes in Uno). So I assume 4 bytes on like the ESP32? A lot assuming going on there.
Check your K&R. Or your copy of the ANSI standard.
unsigned is a type, equivalent to unsigned int.
And…
#include <iostream>
using namespace std;
signed foo;
int main()
{
foo = -777;
cout<<"Hello World "<<foo;
return 0;
}
a7
I kinda would rather be too young to know this.
At least I'm not so old I forgot…
a7
I doubt that I have enough time left to learn all of the intricacies of C and C++. I learn new stuff most every day. I do appreciate being taught be some very knowledgeable folks.
short is equivalent to signed short int
unsigned short is equivalent to unsigned short int
long is equivalent to signed long int
unsigned long is equivalent to unsigned long int
long long is equivalent to signed long long int
unsigned long long is equivalent to unsigned long long int
Ok! so to call it a wrap, you can always declare a type by omitting int (except if declaring a int), so unsigned int is equivalent to unsigned?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.