{"id":8133,"date":"2020-08-27T14:40:38","date_gmt":"2020-08-27T14:40:38","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=8133"},"modified":"2024-02-18T12:52:28","modified_gmt":"2024-02-18T12:52:28","slug":"faq","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=8133","title":{"rendered":"Q&#038;A &#8211; Programming (C++)"},"content":{"rendered":"<p><strong>When do I need the headers for lib files?<\/strong><br \/>\nYou need them during compilation if you build against libraries. You don&#8217;t need them for the execution afterwards.<\/p>\n<hr>\n<p><strong>Why is &#8216;int std::system(const char * command)&#8217; so slow?<\/strong><br \/>\nIt first opens the command-line interpreter of the system (e.g. cmd.exe, \/bin\/sh) and then let&#8217;s it execute the command.<\/p>\n<p>For linux it first calls &#8220;fork();&#8221; and then &#8220;execl(&#8216;\/bin\/sh&#8217;, &#8216;sh&#8217;, &#8216;-c&#8217;, &lt;command&gt;, (char *) NULL);&#8221;.<\/p>\n<p><u>Example<\/u>:<\/p>\n<table>\n<col style=\"width:20%\">\n<col style=\"width:60%\">\n<col style=\"width:20%\">\n<tr>\n<th>Variant<\/th>\n<th>Instruction<\/th>\n<th>Performance<\/th>\n<\/tr>\n<tr>\n<td>Via bash<\/td>\n<td>std::system(&#8216;mount \/dev\/sdb1 \/mnt\/usbdrive&#8217;);<\/td>\n<td>slow<\/td>\n<\/tr>\n<tr>\n<td>Via glibc<\/td>\n<td>mount(&#8216;\/dev\/sdb1&#8217;, &#8216;\/mnt\/usbdrive&#8217;, &#8221;, 0, &#8221;);<\/td>\n<td>fast<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>When do I need the headers for lib files? You need them during compilation if you build against libraries. You<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[27],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/8133"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8133"}],"version-history":[{"count":2,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/8133\/revisions"}],"predecessor-version":[{"id":16937,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/8133\/revisions\/16937"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8133"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}