{"id":6146,"date":"2014-04-13T04:34:38","date_gmt":"2014-04-13T04:34:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/using-include-to-load-opencl-code-collection-of-common-programming-errors-2\/"},"modified":"2014-04-13T04:34:38","modified_gmt":"2014-04-13T04:34:38","slug":"using-include-to-load-opencl-code-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/using-include-to-load-opencl-code-collection-of-common-programming-errors-2\/","title":{"rendered":"Using #include to load OpenCL code-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;ve seen this done long ago with hlsl\/glsl shader code &#8212; using an <code>#include<\/code> on the source code file that pastes the code into a <code>char*<\/code> so that no file IO happens at runtime.<\/p>\n<p>If I were to represent it as pseudo-code, it would look a little like this:<\/p>\n<pre><code>#define CLSourceToString(filename) \" #include \"filename\" \"\nconst char* kernel = CLSourceToString(\"kernel.cl\");\n<\/code><\/pre>\n<p>Now of course that <code>#define<\/code> isn&#8217;t going to work because it&#8217;ll just try to use those quotation marks to start strings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve seen this done long ago with hlsl\/glsl shader code &#8212; using an #include on the source code file that pastes the code into a char* so that no file IO happens at runtime. If I were to represent it as pseudo-code, it would look a little like this: #define CLSourceToString(filename) &#8221; #include &#8220;filename&#8221; &#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6146","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6146"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6146\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}