Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of deprecated C functions?

Tags:

c

I'm a C noob and I just found out that atoi is deprecated in favor of strtol etc.

Where can I find a list of deprecated C functions ?

like image 374
Neeladri Vishweswaran Avatar asked May 23 '10 18:05

Neeladri Vishweswaran


People also ask

What is deprecated in C?

Deprecated attribute in C++14 with Examples Deprecated means the use of the name or entity declared with this attribute is allowed but discouraged for some reason. The compiler gives warnings and if string literals are provided, they are included in warnings.

What does deprecated mean in R?

Deprecated means they don't recommend using it, and that it isn't undergoing further development. But it should not work differently than it did in a previous version unless documentation explicitly states that.


1 Answers

There's a difference between unsafe and deprecated. atoi() is unsafe, however gcc is not going to tell you to stop using it because it's dangerous. Using gets() produces a different result :) YCMV (your compiler may vary).

In general, if a function can fail and no error checking is possible, don't use it. If a function lets you write to a region of memory with out being able to pass a size limit, don't use it.

The latter is easier to determine just by the function prototype. However, if you are somewhat conscious of what you are doing, you'll quickly realize that you have no way of knowing if what you got from atoi() was really the string representation of the result that a user just entered on the command line.

This rationale is not at all exclusive to the standard C library. You will encounter lots and lots of library code, some of it good. No list can replace learned, defensive coding habits.

like image 128
Tim Post Avatar answered Sep 17 '22 20:09

Tim Post