The type void has no size; that would be a compilation error. For the same reason you can't do something like:

void n;

EDIT. To my surprise, doing sizeof(void) actually does compile in GNU C:

$ echo 'int main() { printf("%d", sizeof(void)); }' | gcc -xc -w - && ./a.out 
1

However, in C++ it does not:

$ echo 'int main() { printf("%d", sizeof(void)); }' | gcc -xc++ -w - && ./a.out 
<stdin>: In function 'int main()':
<stdin>:1: error: invalid application of 'sizeof' to a void type
<stdin>:1: error: 'printf' was not declared in this scope
Answer from reko_t on Stack Overflow
๐ŸŒ
Quora
quora.com โ€บ What-is-the-size-of-a-void-data-type
What is the size of a void data type? - Quora
In gcc and in the Apple C compiler you get with XCode (clang), the size of void is โ€œ1โ€ and incrementing a void * pointer changes its value by 1. In c99, or gcc/Apple c with -std=c99 -pendantic, this is a compilat...
People also ask

What is the size of a void pointer in C?
The size of a void pointer ('void*') in C depends on the platform. It normally has the same size as a system regular pointer, which on a 32-bit system is typically 4 bytes and on a 64-bit system is often 8 bytes. The void pointer can point to any sort of object because it is made to contain memory addresses rather than being tied to any particular data type.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ void pointer
Mastering Void Pointers: A Comprehensive Tutorial
Can you delete a void pointer?
The delete operator in C++ or the free() function in C cannot calculate the proper deallocation size for a void pointer because it lacks type information. You must first convert memory allocated via a void pointer to the relevant data type before using the proper deallocation function (such as delete for C++ objects or free() for dynamically allocated memory) to properly release the memory. What is the size of a void pointer in C?
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ void pointer
Mastering Void Pointers: A Comprehensive Tutorial
What cannot be done on the void pointer?
In C or C++, you cannot directly dereference or execute pointer arithmetic on a void pointer ('void*'). Additionally, until you explicitly convert the data to the correct data type, you cannot access the data it points to. To access the underlying data safely, void pointers must first be cast to the correct type because they lack type information. Can you delete a void pointer?
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ void pointer
Mastering Void Pointers: A Comprehensive Tutorial
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ what-is-the-size-of-void-pointer-in-c-cplusplus
What is the size of void pointer in C/C++ ?
The size of void pointer varies system to system. If the system is 16-bit, size of void pointer is 2 bytes. If the system is 32-bit, size of void pointer is 4 bytes. If the system is 64-bit, size of void pointer is 8 bytes. Finding Size of a Void Poi
๐ŸŒ
Medium
medium.com โ€บ @sumeet2703 โ€บ why-void-has-no-size-a-deep-dive-into-c-and-c-34104f886c00
Why void Has No Size: A Deep Dive into C and C++ | by Sumeet K | Medium
September 4, 2024 - This is because the pointer itself has a fixed size, determined by the architecture of the machine, regardless of what type it points to โ€” or even if it points to void. The absence of a defined sizeof(void) is by design. Since void doesnโ€™t represent any specific data, asking for its size is like asking for the size of "nothing." The language designers ensured that this would be a compile-time error to avoid confusion. If you ever find yourself needing to use sizeof(void) for some reason, you are likely approaching the problem from the wrong angle. Instead, consider what you actually need: Is it the size of a pointer?
๐ŸŒ
Unstop
unstop.com โ€บ home โ€บ blog โ€บ void pointer in c explained in detail with code examples
Void Pointer In C Explained In Detail With Code Examples // Unstop
March 1, 2024 - The sizeof() operator can be used to determine the size of a void pointer in C. Given below is the syntax for the same, followed by a code example. ... The sizeof() operator returns the operand's size in bytes.
๐ŸŒ
Scaler
scaler.com โ€บ topics โ€บ void-pointer-in-c
Void Pointer in C - Scaler Topics
October 18, 2022 - Void pointers in C are a special ... ... The size of void pointers varies from machine to machine, but in general they are 4 bytes in 32-bit systems and 8 bytes in 64-bit systems...
๐ŸŒ
Cprogramming
cboard.cprogramming.com โ€บ c-programming โ€บ 120181-void-**-sizeof-void*-what.html
void ** ?? sizeof(void*)?? what is this?
The first will point on the first byte of the 12 bytes that imgtmp->data points, the second on the 4th, the third on the 8th and the fourth on the 12th byte. That way you can use imgtmp->pdata with indexes to get whichever byte you mean. Like imgtmp->pdata[1][2] will give you 2nd row, 3rd column ...
Find elsewhere
๐ŸŒ
upGrad
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ void pointer
Mastering Void Pointers: A Comprehensive Tutorial
October 27, 2025 - It normally has the same size as a system regular pointer, which on a 32-bit system is typically 4 bytes and on a 64-bit system is often 8 bytes. The void pointer can point to any sort of object because it is made to contain memory addresses ...
Top answer
1 of 3
106

Void is considered a data type (for organizational purposes), but it is basically a keyword to use as a placeholder where you would put a data type, to represent "no data".

Hence, you can declare a routine which does not return a value as:

void MyRoutine();

But, you cannot declare a variable like this:

void bad_variable;

However, when used as a pointer, then it has a different meaning:

void* vague_pointer;

This declares a pointer, but without specifying which data type it is pointing to.

2 of 3
38

Yes, void is a type. Whether it's a data type depends on how you define that term; the C standard doesn't.

The standard does define the term "object type". In C99 and earlier; void is not an object type; in C11 and later, it is. In all versions of the standard, void is an incomplete type. What changed in C11 is that incomplete types are now a subset of object types. This is just a change in terminology. (The other kind of type is a function type.)

C99 6.2.6 paragraph 19 says:

The void type comprises an empty set of values; it is an incomplete type that cannot be completed.

The C11 standard changes the wording slightly:

The void type comprises an empty set of values; it is an incomplete object type that cannot be completed.

This reflects C11's change in the definition of "object type" to include incomplete types. It doesn't really change anything about the nature of type void.

The void keyword can also be used in some other contexts:

  • As the only parameter type in a function prototype, as in int func(void), it indicates that the function has no parameters. (C++ uses empty parentheses for this, but they mean something else in C (prior to C23).)

  • As the return type of a function, as in void func(int n), it indicates that the function returns no result.

  • void* is a pointer type that doesn't specify what it points to.

In principle, all of these uses refer to the type void, but you can also think of them as just special syntax that happens to use the same keyword.

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ data-types-in-c
Data Types in C - GeeksforGeeks
C++ #include <stdio.h> // Function with void return type void greet() { printf("Hello, welcome!\n"); } int main() { greet(); return 0; } Output ยท Hello, welcome! The size of the data types in C is dependent on the size of the architecture, so we cannot define the universal size of the data types.
Published ย  June 30, 2015
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ answers โ€บ questions โ€บ 1303937 โ€บ why-are-double-and-void-data-types-but-long-is-not
Why are double and void data types but long is not? - Microsoft Q&A
Since 1.0 can be represented exactly ... to see the difference between a float and a double. You cannot declare a variable to have type void because the language prohibits that....
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Void_type
Void type - Wikipedia
2 weeks ago - A program can convert a pointer to any type of data (except a function pointer) to a pointer to void and back to the original type without losing information, which makes these pointers useful for polymorphic functions. The C language standard does not guarantee that the different pointer types have the same size ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ data-types-in-c-integer-floating-point-and-void-explained
Data Types in C - Integer, Floating Point, and Void Explained
February 1, 2020 - My value is 1 and my size is 4 bytes. Hello! I am a double floating point variable. My value is 3.140000 and my size is 8 bytes. Bye! See you soon. :) The void type specifies that no value is available.
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 5830 โ€บ void-is-also-a-data-type-so-what-is-the-size-of-void-in-bytes
void is also a data type so what is the size of void in bytes | Sololearn: Learn to code for FREE!
0 bytes. There is no size. In other cases there will be compilation errors. Void type doesn't store any value, object or memory. You can't write like this: Void object; ... But it is a data type and it's having some properties so to store that ...
๐ŸŒ
Sankalandtech
sankalandtech.com โ€บ Tutorials โ€บ C โ€บ void-pointer-c.html
void Pointers in C programming.
To use the void pointer in C, You typically need to typecast to the correct data type before dereferencing. Size of the void pointer in C: In C programming, the size of a void pointer is equal to the size of a regular pointer on the system. The size of void pointer can vary based on the system ...
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ c-data-types
C Data Types
For example, ... The size of float (single precision float data type) is 4 bytes. And the size of double (double precision float data type) is 8 bytes. Keyword char is used for declaring character type variables. For example, ... The size of the character variable is 1 byte. void is an incomplete ...
๐ŸŒ
BYJUS
byjus.com โ€บ gate โ€บ void-pointer-in-c
Void Pointer in C
August 1, 2022 - The arithmetic of pointers isnโ€™t possible in the case of void pointers because of their concrete size. 1. Take a look at the following program in C and find out the output for the same: ... The null pointer is basically used in a program to assign the value 0 to a pointer variable of any data type...
๐ŸŒ
Studytonight
studytonight.com โ€บ c โ€บ datatype-in-c.php
C Datatypes - char, int, float, double and void | Studytonight
This data type is mostly used when we define functions. The void datatype is used when a function does not return any result. It occupies 0 bytes of memory. We use the void keyword for void data type. ... Each data type has a size defined in bits/bytes and has a range for the values that these ...