I have made my own source file, and I'm trying to add stddef.h. At compiling I have the following error:
std::ptrdiff_t' has not been declared.
What I've done wrong?
I have made my own source file, and I'm trying to add stddef.h. At compiling I have the following error:
std::ptrdiff_t' has not been declared.
What I've done wrong?
Copyright © 2021 Jogjafile Inc.
The problem is that you are including the standard C header, not the standard C++ header.
The standard C header will not put their symbols in the
std
namespace, since C doesn't have such things.That you have other applications requiring the C header doesn't matter, if you want to use the
ptrdiff_t
type-alias from the C++std
namespace, you must include<cstddef>
.Or stop using
std::ptrdiff_t
and user the unqualified and globalptrdiff_t
from<stddef.h>
.