Linux why not c




















MikeD 4 4 silver badges 16 16 bronze badges. They are different languages. You should probably ask this at StackOverflow or Programmers where the topic has actually been already nicely covered. It'll compile and work as expected. Add a comment. Active Oldest Votes. Improve this answer. Because you want to have one language in project so did the programs bundled with library.

At least that was a story with Gnome. MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI , except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.

Nowadays, you can also consider that In the end it is a quite a historical issue. Community Bot 1. Arturo Hernandez Arturo Hernandez 2 2 silver badges 2 2 bronze badges. Note that it is possible to "convert" libraries to work in the kernel; however, they won't fit well, the process is tedious and error-prone, and there might be significant problems with stack handling the kernel is limited to a small amount of stack space, while userspace programs don't have this limitation causing random memory corruption.

Many of the commonly requested functions have already been implemented in the kernel, sometimes in "lightweight" versions that aren't as featureful as their userland counterparts. Be sure to grep the headers for any functions you might be able to use before writing your own version from scratch. Whenever you feel you need a library function, you should consider your design, and ask yourself if you could move some or all the code into user-space instead.

If you need to use functions from standard library, you have to re-implement that functionality because of a simple reason - there is no standard C library. C library is basically implemented on the top of the Linux kernel or other operating system's kernel.

For instance, C library's mkdir 3 function is basically nothing more than a wrapper for Linux kernel's system call mkdir 2. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Why can't we use C standard library functions in kernel development? Ask Question. Asked 8 years, 11 months ago. Active 3 years, 4 months ago. Viewed 9k times. And the memory footprint for its code is smaller than for most other languages.

One of the main causes for that is exceptions support. Methods of A , B and C classes are defined somewhere else for example in other files. Therefore the compiler cannot analyze them and cannot know if they will throw exceptions.

So it must prepare to handle exceptions thrown from any of their constructors, destructors, or other method calls. Destructors should not throw very bad practice , but the user could throw anyway, or they could throw indirectly by calling some function or method explicitly or implicitly that throws an exception.

If any of the calls in myFunction throw an exception, the stack unwinding mechanism must be able to call all the destructors for the objects that were already constructed. It does this by making use of an auxiliary autogenerated function a kind of look-up table that will be used for stack unwinding in case an exception is thrown from the body of that function, which will be similar to this:.

If the exception is thrown from checkpoints 1 and 9, no object needs destruction. For checkpoint 3, b and a must be destructed. For checkpoint 6, c and a must be destructed. In all cases the destruction order must be respected. For checkpoints 2, 4, 5, 7, and 8, only object a needs to be destructed. This auxiliary function adds size to the code. Many embedded applications cannot afford this extra space. While C does not give you the use of these extra features, it allows a much more compact code footprint than the other languages.

C is not a hard language to learn, so all the benefits from learning it will come quite cheap. As already mentioned, C is a lingua franca for developers. Many implementations of new algorithms in books or on the internet are first or only made available in C by their authors.

This gives the maximum possible portability for the implementation. Be aware that C is an old and widespread language, so you can find all kind of algorithms written in C around the web. And so on. We would rarely discuss or think about the assembly instructions that a portion of code is executing when analyzing the behavior of a portion of code of a high level language. Instead, when discussing what the machine is doing, we speak or think pretty clearly in C. Many interesting projects , from big database servers or operating system kernels, to small embedded applications you can even do at home for your personal satisfaction and fun, are done in C.

Its versatility, efficiency and good performance makes it an excellent choice for high complexity data manipulation software, like databases or 3D animation.

C is still unsurpassed when performance is the priority. The world is running on C-powered devices. We use these devices every day whether we realize it or not. C is the past, the present, and, as far as we can see, still the future for many areas of software.

Subscription implies consent to our privacy policy. Thank you! Open Source Consulting Domain Registration. Visit Jeremy's Blog. Search Blogs. Mark Forums Read. User Name. Remember Me? Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Page 1 of 2. View Public Profile. View Review Entries. Find More Posts by Jatinm. Find More Posts by rgiggs. View LQ Wiki Contributions.

Visit XavierP's homepage!



0コメント

  • 1000 / 1000