Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

c - Mac OS Catalina sbrk is deprecated

I am trying to make my own implementation of a memory allocator in C. When I try to compile my code in the terminal on Mac OS Catalina it says that the function "sbrk" is deprecated. Does anybody know a solution to fix this? The other solutions online have seemed to be a bit outdated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In practice, the term "deprecated" (like the related word "obsolescent") can mean at least three different things:

  1. This feature is expected to be removed in a future release of the { software, standard }. Your code that uses it might stop working then.
  2. We think this feature is Bad, and we think you shouldn't use it.
  3. We thought of a much better version of this feature. We think you should use it instead.

Many times, these meanings are used in combination. One example is the C library function gets(), which just about everyone agrees is Bad (so meaning #2 applies), and has in fact been removed from the C Standard by now (so meaning #1 applies also).

As far as I know, sbrk is an example of meaning #3. There's nothing particularly wrong with it, but there are better and more modern ways of doing the same thing -- although the newer way(s) might also be more complicated, meaning there's an incentive to do it the old way if you want to keep things simple. Other examples of this sort of things are the system calls signal and creat.

At the risk of editorializing (ok, I admit it, I am editorializing), meaning #3 can get interesting when it comes to language or standards evolution. If you believe in backwards compatibility and long-term stability, if you believe programmers ought to be able to write well-intentioned code and have it run forever, you won't throw meaning #1 at them just because meaning #3 applies. But if you want to force people to think like you do, and if you've given up on software stability (since everything's constantly getting rewritten to keep up with new features and new bugs and newly changed standards anyway), and if you think that backwards compatibility is backwards and too much work, you can use meaning #1 all the time, even though it drives me up a tree. :-(


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...