{"id":6089,"date":"2014-04-13T01:15:59","date_gmt":"2014-04-13T01:15:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/cincludepreprocessoropenclstringificationrelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-04-13T01:15:59","modified_gmt":"2014-04-13T01:15:59","slug":"cincludepreprocessoropenclstringificationrelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/cincludepreprocessoropenclstringificationrelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"c++,include,preprocessor,opencl,stringificationRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6f825abb09fd46d88caade666badf547?s=128&amp;d=identicon&amp;r=PG\" \/><br \/>\nMrKatSwordfish<br \/>\ngtk programming gcc c++ gtk3<br \/>\nI&#8217;ve been programming for about a year and a half on Windows and I&#8217;ve just started getting used to the way things work on that platform, but now I&#8217;m interested in development on Linux and I&#8217;ve been having a tough time getting used to the workflow, lack of IDE, and command line compilation with GCC. I&#8217;m running Xubuntu 13.10 64bit, by the way..To test the waters, I did what many people do and wrote a quick C++ &#8216;hello world&#8217; program.#include &lt;iostream&gt;int main() {std::cout &lt;&lt; &#8220;Hello!\\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4e96ca7ae02c37e7d940d17997d780e5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDirk Eddelbuettel<br \/>\nc++ clang<br \/>\nThis seems odd. Take a simple C++ program#include &lt;cmath&gt; #include &lt;iostream&gt;int main(void) {std::cout &lt;&lt; &#8220;Square root of 9 is &#8221; &lt;&lt; sqrt(9) &lt;&lt; std::endl;}which passes fine with g++ (4.8) but fails to compile with clang++ (3.3). edd@don:\/tmp$ g++ -o cmath cmath.cpp edd@don:\/tmp$ .\/cmath Square root of 9 is 3 edd@don:\/tmp$ clang++ -o cmath cmath.cpp In file included from cmath.cpp:2: \/usr\/lib\/gcc\/i686-linux-gnu\/4.8\/..\/..\/..\/..\/include\/c++\/4.8\/cmath:41:10: \\fatal e<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d4f7d15de2abdec49cacaac7d14f00fc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJorge Castro<br \/>\nc++ c<br \/>\nI read somewhere that I need to install &#8216;build essential packager&#8217; &amp; so I tried:sudo apt-get install build-essential Reading package lists&#8230; Done Building dependency tree Reading state information&#8230; Done build-essential is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.But the file still wont compile or run&#8230;gcc -Wall -W -Werror factorial.cpp -o factorial.gives me: gcc -Wall -W -Werror factorial.cpp -o factorial. factorial.cpp:3:22: fatal<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c07163eb387722e5755f70889ebe8f12?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nphilipvr<br \/>\nc++ visual-studio-2010 compiler-errors cpu-architecture<br \/>\nWhen I try to compile my c++ project using Visual Studio 2010 in either Win32 or x64 mode I get the following error:&gt;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include\\winnt.h(135): fatal error C1189: #error : &#8220;No Target Architecture&#8221;My preprocessor definitions say WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)What is causing this error and how do I fix it?\/\/ winnt.h: lines 127-136, MSVS says this is an inactive preprocessor block #if defined(_WIN64)#if defined(_AMD64_) #define PR<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/631f04176f88084e982e7b343c7973f8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEliah Kagan<br \/>\n12.04 ubuntu-netbook compiling c++ c<br \/>\nI have some question about compiling .cpp inside a folder, it says first.cpp No such file or directorybut when I run it in home it compiles. Any settings I might have left out? Thanks.Here&#8217;s the Terminal output (view it bigger):law@ubuntu:~$ ls android-sdk Downloads Pictures test wallpapers android-sdks eclipse Public tomcat workspace Desktop examples.desktop sourcecodescpp Ubuntu One Documents Music Templates Videos<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/taa9C.jpg?s=32&amp;g=1\" \/><br \/>\nFahad Uddin<br \/>\nc++ file file-handling<br \/>\nI am working on files handling in C++ and I am getting a strange error that I can not remove.I am very new to file handling so please help me out.#include&lt;iostream&gt; #include&lt;string&gt; #include&lt;fstream&gt;using namespace std;int main(void) { fstream index; index.open(&#8220;file1&#8221;,ios::app); index&lt;&lt;&#8220;this is the indexed file&#8221;&lt;&lt;endl; index&lt;&lt;&#8220;file name \/t&#8221;&lt;&lt;&#8220;size \/t&#8221;&lt;&lt;&#8220;path&#8221;&lt;&lt;endl; \/\/index.close();string line; string wordtofind; char filename[50]; int cnt;\/<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/456c76a8ac053d511ae75333b8ae38a9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser2179293<br \/>\nc++<br \/>\nI have two files ll.cpp and ll.h both in the same directory.ll.cpp#include &lt;ll.h&gt;#include &lt;iostream&gt;using namespace std;template &lt;class t&gt;LinkedL&lt;t&gt;::LinkedL(){flag=0;head=NULL;tail=NULL;curr=0;}template &lt;class t&gt;LinkedL&lt;t&gt;::void insertS(t inf){Node&lt;t&gt; *n=new Node&lt;t&gt;;n-&gt;next=head;n-&gt;data=inf;head=n;if(curr==0)tail=n;curr++;\/\/cout&lt;&lt;curr&lt;&lt;&#8220;\\n&#8221;;}template &lt;class t&gt;LinkedL&lt;t&gt;::void insertE(t inf){Node&lt;t&gt; *n=new Node&amp;l<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/TFBeI.jpg?s=32&amp;g=1\" \/><br \/>\nmynameisnafe<br \/>\n13.04 xorg c++ opengl makefile<br \/>\nI&#8217;m trying to use GLEW and XServer \/ X11 in a C++ app as instructed in Chapter 15 of the OpenGL Superbible, 5th ed.I&#8217;m using this Makefile:LIBDIRS = -L\/usr\/X11R6\/lib -L\/usr\/X11R6\/lib64 -L\/usr\/local\/lib INCDIRS = -I\/usr\/include -L\/usr\/include CC = g++ CFLAGS = $(COMPILERFLAGS) -g $(INCDIRS) LIBS = -lX11 -lXi -lXmu -lm -lGLEW -lGLU -lGLGLXBasics: GLXBasics.o$(CC) $(CFLAGS) -o GLXBasics $(LIBDIRS) GLXBasics.cpp $(LIBS)clean:rm -f *.oand getting this result:GLXBasics.cpp:4:18: fatal error: glew.h: N<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/32d2ee92e99e287861b25f508416a787?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbluefeet<br \/>\nc++ c berkeley-db<br \/>\nI wrote a program that uses the Berkeley DB in C\/C++ like a mix. I have one class called bdb with this method.int open(char *db_name){flags = DB_CREATE;u_int32_t envCreateFlags = DB_CREATE |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_RECOVER |DB_THREAD;ret = db_env_create(&amp;dbenv, 0);dbenv-&gt;err(dbenv,ret,&#8221;err db_env_create &#8220;); ret = dbenv-&gt;open(dbenv,&#8221;.\/&#8221;,envCreateFlags,0);dbenv-&gt;err(dbenv,ret,&#8221;err db_env_open &#8220;); ret = db_create(&amp;dbp,dbenv, 0); dbp-&gt;err(<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1526bcc445299071f11cdf4913bae0d0?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nuser 123456<br \/>\nc++ c visual-studio-2010 visual-studio visual-c++<br \/>\njust i wanted to make a program using viual stidio 2010 when i do build i have this excaption i just wrote empty main c++ program (no syntax errors)what i got is:1&gt;LINK : error LNK2001: unresolved external symbol _mainCRTStartup 1&gt;c:\\users\\dell\\documents\\visual studio 2010\\Projects\\test\\Debug\\test.exe : fatal error LNK1120: 1 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========code is :#include &lt;iostream&gt; using namespace std;int main() {co<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4e90ec5b3a37364196720ba586c5af33?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJM4<br \/>\nphp include require<br \/>\nI have a script called &#8216;sess-start.php&#8217; which lies in an \/include directory within my httpdocs directory.My site continues to give this error:\\[Fri Mar 25 14:52:24 2011] [error][client 12.3.3.3] PHP Fatal error: require() [function.require]:Failed opening required&#8217;\/includes\/sess-start.php'(include_path=&#8217;.:&#8217;) in\/var\/www\/vhosts\/site.com\/httpdocs\/page.phpon line 4, referer:https:\/\/www.site.com\/even though www.site.com\/includes DOES exist. What gives!Edit 1These are includes\/requires which may thems<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9207dac1a08f23791251e6170b787646?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmiddaparka<br \/>\nphp include<br \/>\nI have a function(this is exactly how it appears, from the top of my file):&lt;?php \/\/dirname(getcwd()); function generate_salt() {$salt = &#8221;;for($i = 0; $i &lt; 19; $i++){$salt .= chr(rand(35, 126));}return $salt; } &#8230;And for some reason, I keep getting the error:Fatal error: Cannot redeclaregenerate_salt() (previously declaredin\/Applications\/MAMP\/htdocs\/question-air\/includes\/functions.php:5)in\/Applications\/MAMP\/htdocs\/question-air\/includes\/functions.phpon line 13I cannot figure out why or how<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/75d8fa0df4b41fe1e7bd9fb2596e6959?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPrafulla<br \/>\nphp file include require-once<br \/>\npublic_html &gt; config.php public_html &gt; A &gt; test_file.phpin test_file.php coderequire_once(&#8220;..\/config.php&#8221;);works fine. shows dynamically-related files fine (config.php) in dreamweaverpublic_html &gt; includes &gt; classes &gt; allclasses.phpin allclasses.php coderequire_once(&#8220;..\/..\/config.php&#8221;);shows dynamically-related files fine (config.php) in dreamweaverwhen I include allclasses.php in test_file.phprequire_once(&#8220;..\/config.php&#8221;); require_once(&#8220;..\/includes\/classes\/allclasses.php&#8221;);sho<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/49862acc65f325f7b33b73f312125a9e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDolph<br \/>\nphp include require-once<br \/>\nI want to fetch div element from other website .on which iam having my profile, i have tried using this code.require_once(&#8216;..\/simple_html_dom.php&#8217;);$html=file_get_html(&#8216;http:\/\/www.example.com&#8217;); $ret=$html-&gt;find(&#8220;div[id=frame-gallery]&#8221;); $ret=array_shift($ret); echo($ret);but this code is giving errorsWarning:require_once(..\/simple_html_dom.php)[function.require-once]: failed toopen stream: No such file or directoryinE:\\wamp\\www\\in.com\\components\\com_content\\view.phpon line 22Fatal error: req<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/graph.facebook.com\/100000875827555\/picture?type=large\" \/><br \/>\nuser3324240<br \/>\njoomla include require fatal-error<br \/>\ni am getting the following error in my joomla websiteFatal error: require(): Failed opening required &#8216;\/homepages\/17\/d492410980\/htdocs\/clickandbuilds\/joomla\/Talentshub\/templates\/jsn_solid_pro\/jsstrings.php&#8217; (include_path=&#8217;.:\/usr\/lib\/php5.4&#8242;) in \/homepages\/17\/d492410980\/htdocs\/clickandbuilds\/joomla\/Talentshub\/templates\/jsn_solid_pro\/index.php on line 73<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.codeproject.com\/script\/Membership\/Images\/member_unknown.gif\" \/><br \/>\njanaswamy uday<br \/>\nfile include<br \/>\nHi All, \u00a0 I have Migrated my existing project from VC2008 to VC2012. \u00a0 while compiling i am getting error as \u00a0 &#8220;C:\\Program Files\\Microsoft Visual Studio 11.0\\VC\\atlmfc\\include\\afxres.h(17): fatal error RC1015: cannot open include file &#8216;winres.h'&#8221; \u00a0 Please let me know where i have gone wrong. \u00a0 Thanks, uday.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2916db0e18bdfa462cc0a60147db754f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser498083<br \/>\nselenium include<br \/>\nI&#8217;ve noticed a problem for nested include function. When I use include in already included html file, selenium ide doesn&#8217;t hide line with include command. Re-execution of scpits doubles number of include calls. As a result of test all the lines with nested include are visible with begin$Template$ and end$Template$ vars and in the other hand, individual calls of include are hidden correctly.command target value type dom=document.getElementsByName(&#8216;City&#8217;)[0] \u00a0type dom=document.getElemen<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c14151894a3089199ff180421c9a2483?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1417332<br \/>\nandroid c android-ndk include dalvik<br \/>\nI want to use below API which is at dalvik\/vm\/native\/dalvik_system_DexFile.cpp:static void Dalvik_dalvik_system_DexFile_defineClass(const u4* args, JValue* pResult)static void Dalvik_dalvik_system_DexFile_openDexFile_bytearray(const u4* args, JValue* pResult)But I don&#8217;t know how can I include proper include files for using above two APIs in libdvm.so.I tried to include whole headers in android project, but it failed with this compile error message: &#8220;Argument list too long&#8221;.Does anybody know what<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8a215bd208f603197c8777579b5a4940?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDSblizzard<br \/>\nwindows qt include<br \/>\nHow can I use windows.h in Qt application? After including it several errors like &#8220;c:\\Qt\\4.4.3\\include\/QtCore\/..\/..\/src\/corelib\/arch\/qatomic_windows.h:387: error: declaration of C function &#8216;long int InterlockedCompareExchange(long int*, long int,long int)&#8217; conflicts with d:\\old\\mingw\\bin..\/lib\/gcc\/mingw32\/4.3.3\/..\/..\/..\/..\/include\/winbase.h:1681: error: previous declaration &#8216;LONG InterlockedCompareExchange(volatile LONG*, LONG,LONG)&#8217; here&#8221; appear. All includes in order: windows.h iostream QtCore<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/KPUcH.png?s=32&amp;g=1\" \/><br \/>\nMechanical snail<br \/>\nsyntax clojure include quoting<br \/>\nI&#8217;m having a hard time understanding (and therefore remembering) the clojure require syntax described here: http:\/\/clojuredocs.org\/clojure_core\/1.3.0\/clojure.core\/require. It seems both counter intuitive and non-uniform.For example, in the following why is this vector required to be quoted:(require &#8216;[clj-json.core :as json])Counter intuitive because normally vectors are not quoted in clojure (lists are quoted and vectors are treated as data). And non-uniform because in this case the vector is NO<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/24d09f66ebe43f79409b6d31431b0dc0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLondonGrammar<br \/>\nc++ preprocessor<br \/>\nI have am getting fatal error C1017: invalid integer constant expression with the following piece of code:#if V1&gt;0 \/\/do stuff #endifV1 is defined as follows at the top of the .cpp file:#define V3 UINT32 #define V4 sizeof(V3) #define V1 (V2 % V4)V2 is defined as follows:const int V2 = 256;Can anybody see where I am going wrong?Thanks in advance!<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/90577b5275e1d208483b844f91a4be3a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\npaxdiablo<br \/>\nc gcc batch-file cygwin preprocessor<br \/>\nI&#8217;m using a proprietary development environment that compiles code written in C, as well as the IEC 61131 languages. For the C compilation, it uses GCC 4.1.2 with these build options: -fPIC -O0 -g -nostartfiles -Wall -trigraphs -fno-asm The compilation is done by a program running on windows utilizing Cygwin.My issue is, IEC language preprocessor is not that useful (doesn&#8217;t support #define at all) and I want to use macros! I don&#8217;t see why the GCC preprocessor would really care what language it i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/axTjh.jpg?s=32&amp;g=1\" \/><br \/>\nConstantine Samoilenko<br \/>\nlinux preprocessor<br \/>\nI&#8217;ve been assigned to cross compile samba 4.0.5 from i686 to MIPS in order to port it on board later. I&#8217;m compiling in ubuntu 13.04 .The error I get is:lib\/sysquotas_4A.c: In function &#8216;sys_get_vfs_quota&#8217;: lib\/sysquotas_4A.c:107:10: error: &#8216;struct dqblk&#8217; has no member named &#8216;dqb_curblocks&#8217; lib\/sysquotas_4A.c:124:10: error: &#8216;struct dqblk&#8217; has no member named &#8216;dqb_curblocks&#8217; lib\/sysquotas_4A.c:170:29: error: &#8216;struct dqblk&#8217; has no member named &#8216;dqb_curblocks&#8217; The following command failed: cc -fno-bu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/eb538603c2b80ea703e92abf5b45c791?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nXeo<br \/>\nc++ c macros preprocessor tilde<br \/>\nSeen on this site, the code shows macro invocations using a tilde in parentheses:HAS_COMMA(_TRIGGER_PARENTHESIS_ __VA_ARGS__ (~)) \/\/ ^^^What does it mean \/ do? I suspect it to just be an empty argument, but I&#8217;m not sure. Is it maybe specific to C(99) like the __VA_ARGS__ is specific to C99 and existent in C++?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3c9058ad4c2f987d74570ff41f04c1c4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngoldfrapp04<br \/>\nc++ qt build preprocessor define<br \/>\nJust a Qt Gui Application with QDialog as the Base Class, the simplest type you can expect. I&#8217;ve programmed on Qt for several times but this is the first time I meet this problem&#8230; I&#8217;ve added minimal code to the program, and here&#8217;s the code in dialog.h (which is mostly automatically generated)#ifndef DIALOG_H #define DIALOG_H#include &lt;QDialog&gt; #include &lt;QPixmap&gt; #include &#8220;bmp.h&#8221;namespace Ui {class Dialog; }class Dialog : public QDialog {Q_OBJECTpublic:explicit Dialog(QWidget *parent<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7e9f797a03b75fb1a2e17fd4f85a0cc2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSaad Imran.<br \/>\nc++ pointers preprocessor class-design<br \/>\nI&#8217;m trying to write 2 classes with members that reference each other. I&#8217;m not sure if I&#8217;m doing something wrong or it&#8217;s just not possible. Can anyone help me out here&#8230;Source.cpp#include &#8220;Headers.h&#8221; using namespace std;void main() {Network* network = new Network();system(&#8220;pause&#8221;);return; }Headers.h#ifndef Headers_h #define Headers_h#include &lt;iostream&gt; #include &lt;vector&gt; #include &#8220;Network.h&#8221; #include &#8220;Router.h&#8221;#endifNetwork.h#include &#8220;Headers.h&#8221;class Network { protected:vector&lt;Rout<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d7487441474a36d6ec1d1a7e9381b327?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJason R. Mick<br \/>\nc++ preprocessor string-literals<br \/>\nGiven an compile-time constant integer (an object, not a macro), can I combine it with a string literal at compile time, possibly with the preprocessor?For example, I can concatenate string literals just by placing them adjacent to each other:bool do_stuff(std::string s); \/\/&#8230; do_stuff(&#8220;This error code is ridiculously long so I am going to split it onto &#8220;&#8221;two lines!&#8221;);Great! But what if I add integer constants in the mix:const unsigned int BAD_EOF = 1; const unsigned int BAD_FORMAT = 2; const<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e23c498970e57702cca5334ca3455f9f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJoe<br \/>\nc++ c preprocessor<br \/>\nI would like to know what the cons are of using the preprocessor in such a way:#define SOME_FUNCTION someFunction(someArgument)Basically I feel like this is wrong (or certainly not a best practice) &#8211; but I&#8217;m not sure why&#8230; my preprocessor skills are rusty at best.thanks, A<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1b2b5d5007262ea3f9e21ab5b15f8b75?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ncasperOne<br \/>\nmatlab design cuda preprocessor<br \/>\nI&#8217;m coding CUDA in Matlab mex-Files. When you look at CUDA examples on the internet or even manuals from nvidia, you often see the use of preprocessing variables to specify the problem size, e.g. the vector length for a vector addition or something like this. I coded my program also like this: Preprocessing Variables for specifying the problem size. And I have to admit it: I like it since you can access those everywhere in your code, e.g. as limits in a loop or something like this, without havin<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ac4441b2d02c6f7bfe99fc15bde827ee?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbhups<br \/>\nc programming-languages preprocessor<br \/>\nI wonder why other languages do not support this feature. What I can understand that C \/ C++ code is platform dependent so to make it work (compile and execute) across various platform, is achieved by using preprocessor directives. And there are many other uses of this apart from this. Like you can put all your debug printf&#8217;s inside #if DEBUG &#8230; #endif. So while making the release build these lines of code do not get compiled in the binary. But in other languages, achieving this thing (later pa<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/61d2bc0830d4865a62c42c5e23a8c85f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nhbdgaf<br \/>\nati gpu opencl<br \/>\nI want to use my GPU with Pyrit. I use Ubuntu 11.10, ATI Radeon HD 68xx and i7 2600K.Step done:Install latest ATI driver from manufacturer website Install AMD APP SDK When I run benchmark I get:~$ pyrit benchmark Pyrit 0.4.0 (C) 2008-2011 Lukas Lueg http:\/\/pyrit.googlecode.com This code is distributed under the GNU General Public License v3+Running benchmark (5037.4 PMKs\/s)&#8230; &#8211; Computed 5037.45 PMKs\/s total. #1: &#8216;CPU-Core (SSE2)&#8217;: 667.8 PMKs\/s (RTT 3.2) #2: &#8216;CPU-Core (SSE2)&#8217;: 661.6 PMKs\/s (RTT<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/Cz7ng.jpg?s=32&amp;g=1\" \/><br \/>\nvandale<br \/>\njava opencl lwjgl<br \/>\nWhen using opencl via LWJGL, I am getting the following error message:# # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000002201971, pid=8476, tid=8920 # # JRE version: 7.0_03-b05 # Java VM: Java HotSpot(TM) 64-Bit Server VM (22.1-b02 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [OpenCL.dll+0x1971] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Win<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc9d9e6dcf4587bc889ca1a7ab7a8a57?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\n14 revs, 2 users 95%huseyin tugrul buyukisik<br \/>\njava opencl jocl<br \/>\nEdit: Problem solved! rzymek&#8217;s answer was helpful.Question: For JOCL, how can I exclude some cores of CPU from the opencl calculations with device fission?(Java port of cl_device_partition_property seems to be corrupt for 0.1.9 version)Edit: I found this:clCreateSubDevices(devices[0][1],core , 1, cpuCores, coreIDs);but java\/jocl doesnt accept this:cl_device_partition_property core=CL.CL_DEVICE_PARTITION_BY_COUNTS;error is:Type mismatch: cannot convert from int to cl_device_partition_propertyJust<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/rOWxx.jpg?s=32&amp;g=1\" \/><br \/>\nRohit Sarewar<br \/>\nhadoop mapreduce opencl gpu jocl<br \/>\nI am using CDH4 and I am trying to access GPU from cleanup() method of mapper class using JOCL. (Note: My normal code(without map reduce) works fine on GPU).When I execute my map-reduce code, It throws an error (specified below).attempt_201309171647_0021_m_000000_1: No protocol specified attempt_201309171647_0021_m_000000_1: No protocol specified 13\/09\/20 18:03:01 INFO mapred.JobClient: Task Id : attempt_201309171647_0021_m_000000_2, Status : FAILED org.jocl.CLException: CL_DEVICE_NOT_FOUNDat or<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0777df4d9cd9e84b45891589b73c0326?s=128&amp;d=identicon&amp;r=PG\" \/><br \/>\nRyan Naddy<br \/>\njava image-processing opencl image-manipulation jocl<br \/>\nI have this simple block of OpenCL code, and I am getting unexpected results. The parameters image is an array of floats and value is a number from -255 to +255. Using java I use a JSlider to change the value. The default value is 0 and the problem is when I move the slider more than 0 the image is black, if I move it less than 0 the image is white, which shouldn&#8217;t happen. This should be checking each pixel individually and adjusting that pixel. It doesn&#8217;t seem to be for some reason.This block o<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b745a94a5174c6829e3487d3107d5707?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nssarangi<br \/>\nopencl<br \/>\nI am continuously getting an Access Violation Error with a all my kernels which I am trying to build. Other kernels which I take from books seem to work fine. https:\/\/github.com\/ssarangi\/VideoCL &#8211; This is where the code is. Something seems to be missing in this. Could someone help me with this. Thanks so much.[James] &#8211; Thanks for the suggestion and you are right. I am doing it on Win 7 with a AMD Redwood card. I have the Catalyst 11.7 drivers with AMD APP SDK 2.5. I am posting the code below.#in<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/91aef7668303115d1faecbc3fb582253?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBart<br \/>\nide opencl<br \/>\nI&#8217;ve got some experience with OpenGL and it&#8217;s programmable pipeline. I&#8217;d like to give OpenCL a try, though.Could somebody propose a nice integrated kit for working with OpenCL?I know only of QuartzComposer which looks nice, but it&#8217;s mac-only. Anyone knows if it supports hand-editing of OpenCL kernels or is it all only through the GUI?Any other Linux \/ Windows alternative?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f96817a4958b8414a464a616a178c999?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTimothy Baldridge<br \/>\nopencl<br \/>\nIs there a way to use C style function pointers in OpenCL?In other words, I&#8217;d like to fill out a OpenCL struct with several values, as well as pointers to a OpenCL function. I&#8217;m not talking about going from a CPU function to a GPU function, I&#8217;m talking about going from a GPU function to a GPU function. Is this possible?&#8212; EDIT &#8212;If not, it there a way around this? In CUDA we have object inheritance, and in 4.0 we even have virtual functions. About the only way I can find to implement a runtime<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d0891b4cc2c23a1995fc113870157b3e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1111929<br \/>\nopencl<br \/>\nGiven a float[n] inputdata to pass to the OpenCL kernel, could anyone enlighten me on the difference between the following three ways to pass this to the kernel:A)cl_mem input = clCreateBuffer(context, CL_MEM_USE_HOST_PTR Sizeof.cl_float * n,inputdata, NULL); clSetKernelArg(kernel, i, Sizeof.cl_mem, Pointer.to(input));B)clSetKernelArg(kernel, i, Sizeof.cl_float * n, Pointer.to(inputdata));C)cl_mem input = clCreateBuffer(context, CL_MEM_options_here, Sizeof.cl_float * n,NULL, NULL); clEnqueueWrit<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a2398e9f6699e05d75f8d465205c6873?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1286187<br \/>\ndriver opencl<br \/>\nI have implemented a project on my computer using AMD SDK v2.5 and ATI Catalyst drivers, as I have an ATI HD5570 graphics card. I would like my executable to run on a different platform. I would like to be able to check whether an available OpenCL platform can be found on the configuration my executable is run. And of course the configuration can have Nvidia graphics card.I have searched over internet but I couldn&#8217;t find a final answer to my question. I am totally lost through my seach. Is there<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a0c394e31c9740376635c8878cf5889e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNone<br \/>\nc function macros stringification<br \/>\nIs there any way to unstringify strings provided as macro arguments? I need to be able to call functions who&#8217;s names are in strings. Something like this:void hello() {printf(&#8220;Hello, world!&#8221;); }call_func(&#8220;hello&#8221;);How would I implement call_func. It would be in a module that would be #included and would be used to call functions in the main c file. If there is another way to do this where the name wouldn&#8217;t have to be in strings but could be passed as an argument to a function that would be ok to.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7d0d66b076e3bc70819e50f8a25af8df?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJonathan Leffler<br \/>\nc++ templates preprocessor stringification<br \/>\nIs it possible in C++ to stringify template arguments? I tried this:#define STRINGIFY(x) #xtemplate &lt;typename T&gt; struct Stringify {Stringify(){cout&lt;&lt;STRINGIFY(T)&lt;&lt;endl;} };int main() {Stringify&lt;int&gt; s; }But what I get is a &#8216;T&#8217;, and not an &#8216;int&#8217;. Seems that the preprocessors kicks in before template resolution.Is there any other way to do this?Is there any way for the preprocessing to take place after template resolution? (Compiler is VC++).<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bba62b5966898855dde021a9a00cfffc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nwwaawaw<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dd11cabc6f1779ffa658654bec8551db?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDan<br \/>\nc++ include preprocessor opencl stringification<br \/>\nNote: This question has nothing to do with OpenCL per se&#8230; check the last paragraph for a succinct statement of my question. But to provide some background:I&#8217;m writing some C++ code that makes use of OpenCL. I like to keep the source for my OpenCL kernels in their own files, to keep coding and maintenance easy (as opposed to embedding the sources directly as string constants in associated C++ code). This inevitably leads to the question of how to load them into the OpenCL runtime once it comes<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MrKatSwordfish gtk programming gcc c++ gtk3 I&#8217;ve been programming for about a year and a half on Windows and I&#8217;ve just started getting used to the way things work on that platform, but now I&#8217;m interested in development on Linux and I&#8217;ve been having a tough time getting used to the workflow, lack of IDE, [&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-6089","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6089","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=6089"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6089\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}