-1

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?

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
infernalcucumber
  • 103
  • 1
  • 12

1 Answers1

3

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 global ptrdiff_t from <stddef.h>.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • @infernalcucumber Yes. – Some programmer dude Sep 29 '16 at 13:10
  • I know, I'm newbie at programing, but do you mean that if I'll include , it should work properly with libraries which are requiring stddef.h ? – infernalcucumber Sep 29 '16 at 13:14
  • I've include instead of , but when i've include libraries generated from matlab simulink coder, at compiling I have following error again: 'std::ptrdiff_t' has not been declared line 72, external location: D:\QNX650\target\qnx6\usr\include\stddef.h – infernalcucumber Sep 29 '16 at 13:19