<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by kahlonel on Medium]]></title>
        <description><![CDATA[Stories by kahlonel on Medium]]></description>
        <link>https://medium.com/@kahlonel?source=rss-c05ebb6d935------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7BFHpDVyMWvVqDKX.jpeg</url>
            <title>Stories by kahlonel on Medium</title>
            <link>https://medium.com/@kahlonel?source=rss-c05ebb6d935------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:51:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kahlonel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tricks every C programmer should know]]></title>
            <link>https://medium.com/@kahlonel/tricks-every-c-programmer-should-know-f5f8cf2d8d1?source=rss-c05ebb6d935------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5f8cf2d8d1</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[kahlonel]]></dc:creator>
            <pubDate>Fri, 17 Feb 2017 22:09:34 GMT</pubDate>
            <atom:updated>2017-02-17T22:19:35.150Z</atom:updated>
            <content:encoded><![CDATA[<p>I compiled a list of notes while reading a book called “Advanced Linux Programming”. I already knew some of those, but rarely keep in mind while doing development. Others, I didn’t have any idea they existed! Here’s the list (still expanding in my laptop):</p><ul><li>You can #define variables in the command line while compiling through GCC. For example, to define NDEBUG while compiling a test.c file do:<br>gcc -o out -D NDEBUG test.c<br>gcc -o out -D NDEBUG=3 test.c</li><li>Compile C programs with -O2 for production binaries.</li><li>Learn to use GDB, especially for quickly finding Segmentation Faults.</li><li>Use getopt_long() for command-line arguments parsing, instead of trying to parse them manually. Very handy!</li><li>stdout is buffered, stderr is not! Which means writing to stderr will immediately be flushed. Writing to stdout, however, will be buffered until later or until a call to fflush(stdout).</li><li>Use mkstemp() and tmpfile() for generating random file names for temporary files.</li><li>Using abort() will generate a core-dump.</li><li>If the library has both an archive (.ar) version and a shared object (.so) version, the program can be linked to the archive using -static. But by default, the shared object version is used.</li><li>The libraries are searched in the current directory first by GCC during compilation.</li><li>Using ldd binary_name will list all needed shared object it needs at runtime. It also lists indirect dependencies, i.e. libraries needed by the directly used libraries.</li><li>A binary can be forced to look for the shared object in a directory using gcc -o app app.c -Wl,-rpath,/path/to/lib/directory. Defining LD_LIBRARY_PATH environment variable is another solution.</li><li>Upgrading shared libraries doesn’t require the binaries to be recompiled/relinked etc.</li><li>Static linking to libraries is good in scenarios where binaries will be installed in a non-privileged environment. So you don’t need sudo make install or sudo apt-get install something.</li><li>Use ps -o pid,ppid,command to get process IDs, and the respective parent process IDs</li><li>Another useful output ps can give is the start time of the process. Use ps -o start_time,command to get the list.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5f8cf2d8d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>