Videos
The answer is no, and for 2 reasons.
- The notion of primitive types in Java exists by opposition to object types. This has no sense in C which is not an object language.
- C intends to be as efficient as possible on any architecture, from 16 or even 8 bits microcontrollers to 64 bits platforms. For that reason the
inttype is generally chosen as the natural type for the architecture provided it contains at least 16 bits. On the other hand, Jave targets maximum portability and fixes the size of all its types.
So even if the list on Wikipedia looks large, it is (unfortunately...) accurate.
C appears to have many, many types, but what if any are considered primitive types.
The Java term "primitive type" distinguishes from reference types. C has no direct analog of Java's reference types, so no need to draw such a distinction.
C does, however, define several categories of types, and among those, the basic types are a reasonably good analogue of Java's primitive types. This category comprises char, the signed and unsigned integer types, and the floating[-point] types. It is ultimately from these, the enumerated types, and type void that all other types are derived, including array types, structure and union types, pointer types, atomic types, and function types.
The basic types can include implementation-defined types, and therefore cannot be exhaustively listed, but those defined by the language spec are:
char
The standard signed integer types
signed char, short int, int, long int, long long int
The standard unsigned integer types
_Bool, unsigned char, unsigned short int, unsigned int, unsigned long int, unsigned long long int
The real floating types
float, double, long double
The complex types
float _Complex, double _Complex, long double _Complex
This is covered in section 6.2.5 of the language spec.
It should be noted that whereas Java specifies the the size and representation of its primitive types, C leaves some of those details of its basic types to implementations, placing constraints on their ranges of representable values and other properties without specifying exact details.
C appears to have many, many types
C has an unbounded number of types, as it provides for types to be derived from other types. The same applies to Java. Ignoring implementation-defined extension types, C has more than twice as many basic types as Java has primitive types, but that's still manageable, especially given the way they are organized.
However, C also has a mechanism for defining type aliases, and a whole family of standard type aliases, and these can make it appear that there are more types than really there are.
It really depends on how you count the data types. This web site lists these 7:
boolcharintfloatdoublevoidwchar_t
However, these types can be modified with signed, unsigned, short, long. The site that you mentioned lists all of these, plus the new ones like char16_t and char32_t. I think that the 28 listed is a very comprehensive list, and I can't think of any that have been omitted (they've even covered unsigned long long int).
So, 28 looks right to me. The reason other sites my have different numbers is because they don't include the new ones, or they don't count all of the modifiers. Other sites may consider unsigned short int different from short unsigned int, but the two are equivalent.
"Primitive data type" is not a term that the standard specifies, so you might get a different answer depending on who you ask. Clang defines the following types as "built-in", meaning that they aren't derived from any other type:
voidboolstd::nullptr_tfloatdoublelong doublechar16_tchar32_tsignedandunsignedvariants of:charwchar_tshortintlonglong long
The list contains more, but I believe that those are the only ones that are specified in standard C++.
The standard has essentially the same thing in [basic.fundamental] (calling these "fundamental types"), but the list isn't as convenient to navigate.
That would be a total of 20 primitive types (ignoring that char and wchar_t are treated separately from their explicitly signed/unsigned variants, because their default signedness is platform-dependent).
The standard also allows implementations to have "extended" signed and unsigned integer types. For instance, Clang supports a signed and unsigned __int128_t, which would fall in that category, but it isn't required by the standard.