How to write "#include <stdlib.h>" to many c files with shell script
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There's one thing about learning techniques for editing multiple files via sed or awk, but don't just blindly add stdlib.h to every file because you "think" you need it. I'm a proponent of not adding include files unless I employ library calls which require those include files. Otherwise one perpetuates this highly lengthy list of include files when they don't really know or care whether or not the list is right, if there are replacements of definitions, or whether or not much of the includes are required. Many's the time I've encountered a lengthy list of includes, some of them standard library ones, but in truth many of them locally defined ones for a particular coding project; where you end up having something defined in duplicate and therefore re-defined to a value you didn't expect. I've seen an include file which checked whether or not a value was defined, performed an undefine action and then forced that value to be what the coder wished. In the end it was "odd" but not destructive; however it made us wary that two or more coders were using the same designations; they were different, and one would win if a particular include file was used. Meanwhile if the other include file was solely used, that definition would still exist, but be a different declaration. As I say, it was not a real problem, but we saw potential there for it to be.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.