What's the difference between cstdlib and stdlib.h?

前端 未结 3 1629
南笙
南笙 2020-12-04 11:53

When writing C++ code is there any difference between:

#include 

and

#include 
3条回答
  •  遥遥无期
    2020-12-04 12:45

    Is there any reason other than coding standards and style to use one over the other?

    Yes. The fact that stdlib.h is deprecated is a very good reason to not use it. It was actually deprecated in the very first standard that came 1998. Sure, it still existed in C++14, and possibly or even probably in C++17 (I don't have access to the C++17 standard) but since it is deprecated it is strong signal that you should not use it. Maybe the risk of removal isn't very high, but why even risk it while writing new code when it is so easy to avoid?

    From C++14 standard:

    These are deprecated features, where deprecated is defined as: Normative for the current edition of the Standard, but having been identified as a candidate for removal from future revisions.

    ...

    You should have a pretty strong argument to use stdlib.h instead of cstdlib

提交回复
热议问题