c++,include,preprocessor,opencl,stringificationRelated issues-Collection of common programming errors
MrKatSwordfish
gtk programming gcc c++ gtk3
I’ve been programming for about a year and a half on Windows and I’ve just started getting used to the way things work on that platform, but now I’m interested in development on Linux and I’ve been having a tough time getting used to the workflow, lack of IDE, and command line compilation with GCC. I’m running Xubuntu 13.10 64bit, by the way..To test the waters, I did what many people do and wrote a quick C++ ‘hello world’ program.#include <iostream>int main() {std::cout << “Hello!\n
Dirk Eddelbuettel
c++ clang
This seems odd. Take a simple C++ program#include <cmath> #include <iostream>int main(void) {std::cout << “Square root of 9 is ” << sqrt(9) << 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
Jorge Castro
c++ c
I read somewhere that I need to install ‘build essential packager’ & so I tried:sudo apt-get install build-essential Reading package lists… Done Building dependency tree Reading state information… 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…gcc -Wall -W -Werror factorial.cpp -o factorial.gives me: gcc -Wall -W -Werror factorial.cpp -o factorial. factorial.cpp:3:22: fatal
philipvr
c++ visual-studio-2010 compiler-errors cpu-architecture
When I try to compile my c++ project using Visual Studio 2010 in either Win32 or x64 mode I get the following error:>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(135): fatal error C1189: #error : “No Target Architecture”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
Eliah Kagan
12.04 ubuntu-netbook compiling c++ c
I 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’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
Fahad Uddin
c++ file file-handling
I 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<iostream> #include<string> #include<fstream>using namespace std;int main(void) { fstream index; index.open(“file1”,ios::app); index<<“this is the indexed file”<<endl; index<<“file name /t”<<“size /t”<<“path”<<endl; //index.close();string line; string wordtofind; char filename[50]; int cnt;/
user2179293
c++
I have two files ll.cpp and ll.h both in the same directory.ll.cpp#include <ll.h>#include <iostream>using namespace std;template <class t>LinkedL<t>::LinkedL(){flag=0;head=NULL;tail=NULL;curr=0;}template <class t>LinkedL<t>::void insertS(t inf){Node<t> *n=new Node<t>;n->next=head;n->data=inf;head=n;if(curr==0)tail=n;curr++;//cout<<curr<<“\n”;}template <class t>LinkedL<t>::void insertE(t inf){Node<t> *n=new Node&l
mynameisnafe
13.04 xorg c++ opengl makefile
I’m trying to use GLEW and XServer / X11 in a C++ app as instructed in Chapter 15 of the OpenGL Superbible, 5th ed.I’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
bluefeet
c++ c berkeley-db
I 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(&dbenv, 0);dbenv->err(dbenv,ret,”err db_env_create “); ret = dbenv->open(dbenv,”./”,envCreateFlags,0);dbenv->err(dbenv,ret,”err db_env_open “); ret = db_create(&dbp,dbenv, 0); dbp->err(
user 123456
c++ c visual-studio-2010 visual-studio visual-c++
just 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>LINK : error LNK2001: unresolved external symbol _mainCRTStartup 1>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 <iostream> using namespace std;int main() {co
JM4
php include require
I have a script called ‘sess-start.php’ 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’/includes/sess-start.php'(include_path=’.:’) 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
middaparka
php include
I have a function(this is exactly how it appears, from the top of my file):<?php //dirname(getcwd()); function generate_salt() {$salt = ”;for($i = 0; $i < 19; $i++){$salt .= chr(rand(35, 126));}return $salt; } …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
Prafulla
php file include require-once
public_html > config.php public_html > A > test_file.phpin test_file.php coderequire_once(“../config.php”);works fine. shows dynamically-related files fine (config.php) in dreamweaverpublic_html > includes > classes > allclasses.phpin allclasses.php coderequire_once(“../../config.php”);shows dynamically-related files fine (config.php) in dreamweaverwhen I include allclasses.php in test_file.phprequire_once(“../config.php”); require_once(“../includes/classes/allclasses.php”);sho
Dolph
php include require-once
I want to fetch div element from other website .on which iam having my profile, i have tried using this code.require_once(‘../simple_html_dom.php’);$html=file_get_html(‘http://www.example.com’); $ret=$html->find(“div[id=frame-gallery]”); $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
user3324240
joomla include require fatal-error
i am getting the following error in my joomla websiteFatal error: require(): Failed opening required ‘/homepages/17/d492410980/htdocs/clickandbuilds/joomla/Talentshub/templates/jsn_solid_pro/jsstrings.php’ (include_path=’.:/usr/lib/php5.4′) in /homepages/17/d492410980/htdocs/clickandbuilds/joomla/Talentshub/templates/jsn_solid_pro/index.php on line 73
janaswamy uday
file include
Hi All, I have Migrated my existing project from VC2008 to VC2012. while compiling i am getting error as “C:\Program Files\Microsoft Visual Studio 11.0\VC\atlmfc\include\afxres.h(17): fatal error RC1015: cannot open include file ‘winres.h'” Please let me know where i have gone wrong. Thanks, uday.
user498083
selenium include
I’ve noticed a problem for nested include function. When I use include in already included html file, selenium ide doesn’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(‘City’)[0] type dom=document.getElemen
user1417332
android c android-ndk include dalvik
I 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’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: “Argument list too long”.Does anybody know what
DSblizzard
windows qt include
How can I use windows.h in Qt application? After including it several errors like “c:\Qt\4.4.3\include/QtCore/../../src/corelib/arch/qatomic_windows.h:387: error: declaration of C function ‘long int InterlockedCompareExchange(long int*, long int,long int)’ conflicts with d:\old\mingw\bin../lib/gcc/mingw32/4.3.3/../../../../include/winbase.h:1681: error: previous declaration ‘LONG InterlockedCompareExchange(volatile LONG*, LONG,LONG)’ here” appear. All includes in order: windows.h iostream QtCore
Mechanical snail
syntax clojure include quoting
I’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 ‘[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
LondonGrammar
c++ preprocessor
I have am getting fatal error C1017: invalid integer constant expression with the following piece of code:#if V1>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!
paxdiablo
c gcc batch-file cygwin preprocessor
I’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’t support #define at all) and I want to use macros! I don’t see why the GCC preprocessor would really care what language it i
Constantine Samoilenko
linux preprocessor
I’ve been assigned to cross compile samba 4.0.5 from i686 to MIPS in order to port it on board later. I’m compiling in ubuntu 13.04 .The error I get is:lib/sysquotas_4A.c: In function ‘sys_get_vfs_quota’: lib/sysquotas_4A.c:107:10: error: ‘struct dqblk’ has no member named ‘dqb_curblocks’ lib/sysquotas_4A.c:124:10: error: ‘struct dqblk’ has no member named ‘dqb_curblocks’ lib/sysquotas_4A.c:170:29: error: ‘struct dqblk’ has no member named ‘dqb_curblocks’ The following command failed: cc -fno-bu
Xeo
c++ c macros preprocessor tilde
Seen 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’m not sure. Is it maybe specific to C(99) like the __VA_ARGS__ is specific to C99 and existent in C++?
goldfrapp04
c++ qt build preprocessor define
Just a Qt Gui Application with QDialog as the Base Class, the simplest type you can expect. I’ve programmed on Qt for several times but this is the first time I meet this problem… I’ve added minimal code to the program, and here’s the code in dialog.h (which is mostly automatically generated)#ifndef DIALOG_H #define DIALOG_H#include <QDialog> #include <QPixmap> #include “bmp.h”namespace Ui {class Dialog; }class Dialog : public QDialog {Q_OBJECTpublic:explicit Dialog(QWidget *parent
Saad Imran.
c++ pointers preprocessor class-design
I’m trying to write 2 classes with members that reference each other. I’m not sure if I’m doing something wrong or it’s just not possible. Can anyone help me out here…Source.cpp#include “Headers.h” using namespace std;void main() {Network* network = new Network();system(“pause”);return; }Headers.h#ifndef Headers_h #define Headers_h#include <iostream> #include <vector> #include “Network.h” #include “Router.h”#endifNetwork.h#include “Headers.h”class Network { protected:vector<Rout
Jason R. Mick
c++ preprocessor string-literals
Given 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); //… do_stuff(“This error code is ridiculously long so I am going to split it onto “”two lines!”);Great! But what if I add integer constants in the mix:const unsigned int BAD_EOF = 1; const unsigned int BAD_FORMAT = 2; const
Joe
c++ c preprocessor
I 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) – but I’m not sure why… my preprocessor skills are rusty at best.thanks, A
casperOne
matlab design cuda preprocessor
I’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
bhups
c programming-languages preprocessor
I 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’s inside #if DEBUG … #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
hbdgaf
ati gpu opencl
I 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)… – Computed 5037.45 PMKs/s total. #1: ‘CPU-Core (SSE2)’: 667.8 PMKs/s (RTT 3.2) #2: ‘CPU-Core (SSE2)’: 661.6 PMKs/s (RTT
vandale
java opencl lwjgl
When 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
14 revs, 2 users 95%huseyin tugrul buyukisik
java opencl jocl
Edit: Problem solved! rzymek’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
Rohit Sarewar
hadoop mapreduce opencl gpu jocl
I 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
Ryan Naddy
java image-processing opencl image-manipulation jocl
I 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’t happen. This should be checking each pixel individually and adjusting that pixel. It doesn’t seem to be for some reason.This block o
ssarangi
opencl
I 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 – This is where the code is. Something seems to be missing in this. Could someone help me with this. Thanks so much.[James] – 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
Bart
ide opencl
I’ve got some experience with OpenGL and it’s programmable pipeline. I’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’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?
Timothy Baldridge
opencl
Is there a way to use C style function pointers in OpenCL?In other words, I’d like to fill out a OpenCL struct with several values, as well as pointers to a OpenCL function. I’m not talking about going from a CPU function to a GPU function, I’m talking about going from a GPU function to a GPU function. Is this possible?— EDIT —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
user1111929
opencl
Given 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
user1286187
driver opencl
I 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’t find a final answer to my question. I am totally lost through my seach. Is there
None
c function macros stringification
Is there any way to unstringify strings provided as macro arguments? I need to be able to call functions who’s names are in strings. Something like this:void hello() {printf(“Hello, world!”); }call_func(“hello”);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’t have to be in strings but could be passed as an argument to a function that would be ok to.
Jonathan Leffler
c++ templates preprocessor stringification
Is it possible in C++ to stringify template arguments? I tried this:#define STRINGIFY(x) #xtemplate <typename T> struct Stringify {Stringify(){cout<<STRINGIFY(T)<<endl;} };int main() {Stringify<int> s; }But what I get is a ‘T’, and not an ‘int’. 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++).
wwaawaw
Dan
c++ include preprocessor opencl stringification
Note: This question has nothing to do with OpenCL per se… check the last paragraph for a succinct statement of my question. But to provide some background:I’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
Web site is in building