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...
🌐
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 ...
🌐
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
Find elsewhere
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.

🌐
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 ...
🌐
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 ...
🌐
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 ...
🌐
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....
🌐
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 ...
🌐
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...
🌐
University of Hawaii
ee.hawaii.edu › ~tep › EE160 › Book › chap5 › subsection2.1.3.1.html
5.3.1 Data Type void
/* File: msg.c This program introduces data type void. */ ... /* Function prints a message. */ void printmsg(void) { printf("****HOME IS WHERE THE HEART IS****\n"); } No parameters are required for the function, printmsg(), and it returns no value; it merely prints its message. In the function call in main(), parentheses must be used without any arguments. Observe that no return statement is present in printmsg(). When a function is called, the body is executed and, when the end of the body is reached, program control returns to the calling function.
🌐
Reddit
reddit.com › r/c_programming › eli5: void in c
r/C_Programming on Reddit: ELI5: Void in C
March 8, 2024 -

I just began studying C and I cannot, for the life of me, understand void.

I have read and listened to many people say "It does not return a value". Ok? What is a value? Why wouldn't we want to return it? What is the difference between "void main" and "int main"? Can we just use int for everything and ignore void altogether?

In what situations is void used? In what situations is void better? etc. Please help I don't get it at all!

🌐
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 ...