c++

Can i call multiple times JNI_CreateJavaVM ?

Hello I´m Trying to launch two threads witch calls "DispFrontEnd" function First thread ended OK, second failed to start jvm.. ?? tks #include "jni.h" #include <process.h> #include "Stdafx.h" //DISPATCH Thread Check bool DispatchThreadCreated = FALSE; if (DispatchThreadCreated == FALSE) { HANDLE hDispThread; hDispThread = (H...

std::vector overwriting final value, rather than growing?

I'm having an issue where using vector.push_back(value) is overwriting the final value, rather than appending to the end. Why might this happen? I have a sample item in the vector, so it's size never hits zero. Below is the code.. void UpdateTable(vector<MyStruct> *Individuals, MyStruct entry) { MyStruct someEntry; bool isNew...

load ppm file using glut

I want to do a texture mapping to a PPM file in C++. Is there some way I can load the PPM file. Thanks. ...

Pass C# string to C++ and pass C++ result (string, char*.. whatever) to C#

I tried different things but i'm getting mad with Interop. (here the word string is not referred to a variabile type but "a collection of char"): I have an unmanaged C++ function, defined in a dll, that i'm trying to access from C#, this function has a string parameter and a string return value like this: string myFunction(string input...

Python method to boost function

I have a method exported to Python using boost python that takes a boost::function as an argument. From what I have read boost::python should support boost::function without much fuss, but when I try to call the function with a python method it gives me this error Boost.Python.ArgumentError: Python argument types in Class.createTim...

How do you read a segfault kernel log message.

This can be a very simple question, I'm am attempting to debug an application which generates the following segfault error in the kern.log kernel: myapp[15514]: segfault at 794ef0 ip 080513b sp 794ef0 error 6 in myapp[8048000+24000] Here are my questions: Is there any documentation as to what are the diff error numbers on segfault, ...

How to structure data for optimal speed in a CUDA app

I am attempting to write a simple particle system that leverages CUDA to do the updating of the particle positions. Right now I am defining a particle has an object with a position defined with three float values, and a velocity also defined with three float values. When updating the particles, I am adding a constant value to the Y com...

Best way to parse HTML in Qt?

How would I go about parsing all of the "a" html tags "href" properties on a page full of BAD html, in Qt? ...

LoadString, static library and executables

My project is set up so all the framework code and modules are compiled to a static .lib (let's call it framework.lib), and many test projects use framework.lib and compile to executable files. For error handling, I'm trying to put the resource strings in framework.rc (part of the framework.lib project) and load the strings in the exe...

C++ standard/de facto STL algorithm wrappers.

hello Are there any standard/de facto standard (boost) wrappers around standard algorithms which work with containers defining begin and end. Let me show you what I mean with the code: // instead of specifying begin and end std::copy(vector.begin(), vector.end(), output); // write as xxx::copy(vector, output); I know it can be writte...

How does QDebug() << stuff; add a newline automatically?

I'm trying to implement my own QDebug() style debug-output stream, this is basically what I have so far: struct debug { #if defined(DEBUG) template<typename T> std::ostream& operator<<(T const& a) const { std::cout << a; return std::cout; } #else template<typename T> debug const& operator<<(T cons...

Can I force a parent window to redraw without causing its children to redraw?

Is it possible to invalidate a window without invalidating its children? (display invalidation to cause a repaint of the parent window, but not redraw its children) This assumes that the parent window already has the "clipchildren" style, so that its painting wouldn't inherently invalidate the children. ...

How do you use the immediate window in VS for C++?

So, I have a vector std::vector<std::string> lines. I fill this vector up, and can access it like std::string temp = lines[0]; However, in the immediate window, both lines[0] - error:overloaded operator not found and lines.at(0) - error:symbol is ambiguous don't work at all. Is there a trick to using the immediate wind...

can anybody offer a simple hash_map example in C++?

Hi, I heard a lot about hash function but I don't know how to use it in C++. I learnt that we can use hash_map. Does g++ support that by simply including #include <hash_map>? Can anybody offer me a simple example using hash_map? Thanks a lot! ...

C++ Adobe source libraries impressions?

hello I just stumbled upon Adobe source libraries, ASL. It is set of templates and functions similar to boost, under MIT license. Some of the utilities in the library I found quite useful and now I consider using it. the library seems pretty straightforward, however. Have you used ASL yourself? if so, what were your impressions? do y...

Can anyone explain event handling in C++ please?

I should mention that i am using Mac OS X, XCode. When a buffer has finished writing to file, it generates an event to tell the gui to read the data off the file. I am not sure what kind of event would i need in this case? Is it possible to do it without using event? Thank you. ...

g++ compilation error of another thing that works in msvs.

Heya, folks. I'm porting some code from a project largely developed in MSVS to use g++. I've found a lot of little differences, mostly things that MSVS allows but g++ does not. Usually it's something involving c++ standards, things that MSVS lets slide, but I'm having trouble seeing just what's wrong with one particular section. g++ is ...

State machine implementation

I have a state machine as described below. We can start in one of two starting states, but we must hit all 4 states of the handshake. From there, we can either transfer a payload of data or receive a payload of data. Then, we return to our original starting state. Handshake: -> StartingState1 -> FinalState1 -> StartingState2 -> FinalS...

Visualization from C/C++ via Gnuplot's pipe interface

I am attempting to use the pipe interface to gnuplot (a standard one gnuplot_i.{cpp,hpp}) in order to generate a real time display of values that are continually changing within another program written in C++. This works ok but I wanted to see if anyone had any suggestions for improvement. This implementation contains a convenience met...

In C++, are static initializations of primitive types to constant values thread-safe?

i.e., would the following be expected to execute correctly even in a multithreaded environment? int dostuff(void) { static int somevalue = 12345; return somevalue; } Or is it possible for multiple threads to call this, and one call to return whatever garbage was at &somevalue before execution began? ...