c++

Is it recommend to trap SIGPIPE in bash script?

Hi, I have a problem while executing a bash script from C++ using the system call command. The script catch a SIGPIPE signal and exit with ret code 141. This problem has started to appear only in the last release of my code. My Questions are as follows: 1) Why does this SIGPIPE occur now and didn't occur before? 2) Is it safe to ignor...

Link error: unresolved operator << for std::basic_ostream with CStringT

I just reorganized some libraries of my Visual C++ (7.1) project and got trouble with the linker i cannot resolve. The Project links MFC as well as Standard Windows Libraries, all MBCS Somewhere, there is something like : std::stringstream sstr; sstr << m_MyCStringVar << std::endl; (this line, as well as some others, needs << for ba...

How to get Shared Object in Shared Memory

Our app depends on an external, 3rd party-supplied configuration (including custom driving/decision making functions) loadable as .so file. Independently, it cooperates with external CGI modules using a chunk of shared memory, where almost all of its volatile state is kept, so that the external modules can read it and modify it where ap...

openMP question

hello all, is it suitable parallelizing loops containing function call(s). or is it much more convenient parallelization of loops which are doing basic operation inside. for example is it suitable putting parallelization directives as below ? main(){ .. #omp paralel .. for (i=0;i<100;i++){ a[i] = foo(&datatype , ...); ... } .. } int ...

Can we use a timer for itself?

Actually this is what i want to do; When a condition appears, my program will close itself and after five minutes it will re-open. Is it possible with only one .exe -by using any OS property-? I do it with two .exe if (close_condition){ //call secondary program system ("secondary.exe"); return (0); } and my secondar...

[c++winsock2.0]How to abort winsock blocking call ?

I use Winsock 2 in C++, and wonder how to make my server stop reading from the client connection. The reading thread gets blocked in recv() and I have no idea how to abort it. One way to do this is use non-blocking sockets with select(), but this thread has to wait before checking the new select(). What is the proper way to stop readin...

recv() with errno=107:(transport endpoint connected)

well..I use a typical model of epoll+multithread to handle massive sockets, that is, I have a thread called epollWorkThread that use epoll_wait to handle i/o sockets. While there's an event of EPOLLIN, recv() will do the work and I do use the noblocking mode to allow immediate return. And recv() is indeed in a while(true) loop. Everythin...

How to implement a basic Variant (& a visitor on the Variant) template in C++?

I have tried reading: http://www.boost.org/doc/libs/1_41_0/boost/variant.hpp http://www.codeproject.com/KB/cpp/TTLTyplist.aspx and chapter 3 of "Modern C++ Design" but still don't understand how variants are implemented. Can anyone paste a short example of how to define something like: class Foo { void process(Type1) { ... }; ...

Why am I getting a segmentation fault?

I am trying to compile a simple hello world function in c++. After I compile it, I run it and get "Segmentation fault". Can someone shed some light on this? I am compiling this from a Linux command line using the following command: g++ hello.cpp #include <iostream> using namespace std; int main() { cout << "Hello World!" << ...

Get localized date time string and time zone name in differnet languages on windows.

Is there any windows API or language feature (C++,C#) to get the time, date and time zone name in localized format for different languages? EDIT: In C# I can get the localized strings for date and time, but it seems TimeZoneInfo doesn't have localized strings. I also didn't find it in the registry. Most probably you need to translate ti...

Trusting the Return Value Optimization

How do you go about using the return value optimization? Is there any cases where I can trust a modern compiler to use the optimization, or should I always go the safe way and return a pointer of some type/use a reference as parameter? Is there any known cases where the return value optimization cant be made?, Seems to me that the retu...

Recursive and non recursive procedures for trees

Dear Sir! as we know that the trees are recursive data structures, We use recurrsion in writing the procedures of tree like delete method of BST etc. the advantage of recurrsion is, our procedures becomes very small (for example the code of inorder traversal is of only 4 or 5 lines) rather than a non recurrsive procedure which would be...

Declare in C == define in C++ ?

Possible Duplicate: What is the difference between a definition and a declaration? Is it correct that to declare in C is equal to define in C++? int a; /* to declare variabel a in C */ int b = 2; /* to declare and initialize in C */ int c; // to define in C++ int d = 4; // to define and initialize in C++ ...

Grab Mac OS Screen using GL_RGB format

Hi, I'm using the glgrab code to try and grab a full-screen screenshot of the Mac screen. However, I want the bitmap data to be in the GL_RGB format. That is, each pixel should be in the format: 0x00RRGGBB The original code specified the GL_BGRA format. However, changing that to GL_RGB gives me a completely blank result. The total sou...

what does malloc(0) return ?

What does malloc(0) returns? Would the answer be same for realloc(malloc(0),0) ? #include<stdio.h> #include<malloc.h> int main() { printf("%p\n", malloc(0)); printf("%p\n", realloc(malloc(0), 0)); return 0; } Output from linux gcc: manav@manav-workstation:~$ gcc -Wall mal.c manav@manav-workstation:~$ ./a.out 0...

How to get a message request from its sequence number?

Given a sequence number, I need to find the corresponding request message string. I can't find a way to it easily do that with quickFix lib. To be short, I've had the idea to use the FileStore "body" file to help me retrieve the message request string from a sequence number,as the FileStore class exposes a convenient method: get(int be...

Warning C4251 when building a DLL that exports a class containing an ATL::CString member

I am converting an ATL-based static library to a DLL and am getting the following warning on any exported classes that use the ATL CString class (found in atlstr.h): warning C4251: 'Foo::str_' : class 'ATL::CStringT' needs to have dll-interface to be used by clients of class 'Foo' I am correctly declaring the Foo class as exp...

Externalizing parameters for VS2008 C++ project compilation

Is there some way to externalize the paths of libraries that are used in the compilation process on Visual Studio 2008? Like, *.properties files? My goal is to define "variables" referencing locations to headers files and libraries, like *.properties files are used in the Ant build system for Java. ...

Passing platform-specific data in a platform independent design?

I have a game engine design written in C++ where a platform-independent game object is contained within a platform-specific Application object. The problem I'm trying to solve is the case where I need to pass OS-specific data from the Application to the game. In this case, I'd need to pass the main HWND from Windows for DirectX or an O...

How to get Default JVM INITIAL ARGS In JNI

I'm trying to get the default jvm args of the available JVM but I'm getty a strange output. Anyone can point me to what's wrong? Output: 65542 �p����Y����k�.L�R���g���J����sk��,��*�Jk��xk�� Code: #include "jni.h" #include <iostream> #include <dlfcn.h> #include <cstdlib> using namespace std; void * JNI_FindCreateJavaVM(char *vmlibp...