{"id":191,"date":"2014-08-30T14:58:10","date_gmt":"2014-08-30T12:58:10","guid":{"rendered":"https:\/\/kszyh.kisim.eu.org\/?p=191"},"modified":"2014-08-30T14:58:10","modified_gmt":"2014-08-30T12:58:10","slug":"zbedne-include-w-c","status":"publish","type":"post","link":"https:\/\/kszyh.kisim.eu.org\/?p=191","title":{"rendered":"Zb\u0119dne #include w C++"},"content":{"rendered":"<pre class=\"lang:sh decode:true \">#!\/bin\/bash\r\n# prune include files one at a time, recompile, and put them back if it doesn't compile\r\n# arguments are list of files to check\r\nremoveinclude() {\r\n    file=$1\r\n    header=$2\r\n    perl -i -p -e 's+([ \\t]*#include[ \\t][ \\t]*[\\\"\\&lt;]'$2'[\\\"\\&gt;])+\/\/REMOVEINCLUDE $1+' $1\r\n}\r\nreplaceinclude() {\r\n   file=$1\r\n   perl -i -p -e 's+\/\/REMOVEINCLUDE ++' $1\r\n}\r\n\r\nfor file in $*\r\ndo\r\n    #echo $file\r\n    includes=`grep \"^[ \\t]*#include\" $file | awk '{print $2;}' | sed 's\/[\\\"\\&lt;\\&gt;]\/\/g'`\r\n    echo $includes\r\n    for i in $includes\r\n    do\r\n        touch $file # just to be sure it recompiles\r\n        removeinclude $file $i\r\n        if make -j10 &gt;\/dev\/null  2&gt;&amp;1;\r\n        then\r\n            grep -v REMOVEINCLUDE $file &gt; tmp &amp;&amp; mv tmp $file\r\n            echo removed $i from $file\r\n        else\r\n            replaceinclude $file\r\n            echo $i was needed in $file\r\n        fi\r\n    done\r\ndone<\/pre>\n<p>Skrypt usuwa kolejne <em>#include<\/em> a nast\u0119pnie rekompiluje kod by sprawdzi\u0107 czy nadal dzia\u0142a. Jako argument skrypt przyjmuje katalog z plikami do sprawdzenia.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash # prune include files one at a time, recompile, and put them back if it doesn&#8217;t compile # arguments are list of files to check removeinclude() { file=$1 header=$2 perl -i -p -e 's+([ \\t]*#include[ \\t][ \\t]*[\\&#8221;\\&lt;]&#8217;$2&#8242;[\\&#8221;\\&gt;])+\/\/REMOVEINCLUDE $1+&#8217; $1 } replaceinclude() { file=$1 perl -i -p -e 's+\/\/REMOVEINCLUDE ++&#8217;&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/kszyh.kisim.eu.org\/?p=191\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,9,23],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-c","category-lifehacking","category-linux"],"_links":{"self":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":1,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":192,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions\/192"}],"wp:attachment":[{"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kszyh.kisim.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}