Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type long Vs Type long int

Tags:

c

What would following typedef mean, and why would it be required

typedef unsigned long int ULONG;

how different is it from

typedef unsigned long ULONG;

For gcc sizeof int = 4, sizeof long = 8, and sizeof ULONG = 8.

like image 215
Kamath Avatar asked Dec 06 '22 14:12

Kamath


2 Answers

They are the same. Because long is a modifier for an int by default, int can be omitted. The same goes for short and short int, unsigned and unsigned int, etc.

The essential thing to understand here is that long, short and unsigned are type modifiers, not types themselves, unlike int, char, double, etc.

like image 147
Blagovest Buyukliev Avatar answered Dec 18 '22 09:12

Blagovest Buyukliev


There's no difference at all. long is synonymous with long int (just as short is with short int).

like image 37
Jerry Coffin Avatar answered Dec 18 '22 09:12

Jerry Coffin