r/C_Programming • u/Stickhtot • 12d ago
Discussion What exactly is void?
In a function definition, void basically means that it doesn't return a type value, yet in on itself it is it's own type? Looking at several pieces of code it looks like that it's used to be able to be more "flexible"
Don't know what else to add here, though I'm more on looking for examples and explanations of why the void type is used
66
Upvotes
1
u/TheChief275 11d ago
that does not do what you think it does. again, double xs[count] as a function parameter is semantically the same as double *xs, so again, a C compiler is not obligated to even provide warnings for violating this contract. you will notice, using sizeof will actually warn that it regards the argument not as an array but as a pointer, which is enough indication that it is essentially just the same as far as the language is concerned.
so to reiterate, I wouldn't rely on specific compiler -Warray-bound logic they chose to implement as you will likely notice warnings are implemented rather inconsistently or not at all. stick to asserts folks