c++

How to pass Object array to unmanaged code?

I'm trying to pass an array of objects from C# to unmanaged C++, and nothing seems to work. The compiler won't let me pretend the array is an IntPtr. Casting the array to an IntPtr doesn't work. I've tried to pass the address of pinned data, but this didn't work either. I just need to pass a pointer to the beginning of the array, and...

Image Processing on GPU- sucessive shaders for filters - FBO

Hi all, I'm currently trying to implement in OpenGL image processing algorithms. I would like to successively use several shaders in order to perform several filters (Sobel Gaussian,...). I understood that to do thius I had to render to texture thanks to a FBO. I read a lot of things about that, and wrote a code. But I'm not getting th...

Is it possible to specialize template with pointer to function type that way it can see all the types used in this pointer separately?

#include <iostream> template<typename T_function_type> struct pointer_wrapper { T_function_type function_pointer; explicit pointer_wrapper(T_function_type ptr) : function_pointer(ptr) { } ~pointer_wrapper() { } }; template<typename T_return, typename T_arg1, typename T_arg2> pointer_wrapper<T_return (*)(T_arg1, T_arg2)>...

Buffer too small when copying a string using wcsncpy_s.

This C++ code is kind of lame, but I need to maintain it. I cannot seem to figure out a "buffer too small" problem. I am using Visual Studio 2010. I will come up with minimal code required to reproduce based on the values I see in the debugger. Sorry, I will not have tested the actual snippet itself. Also, since my system clipboard is "b...

Main only recieving first letters of arguments

int _tmain(int argc, char** argv) { FILE* file1=fopen(argv[1],"r"); FILE* file2=fopen(argv[2],"w"); } It seems as if only the first letter of the arguments is received... I dont get why! std::cout<<"Opening "<<strlen(argv[1])<<" and writing to "<<strlen(argv[2])<<std::endl; outputs 1 and 1 no matter wha...

C++: Difficulty with partial application

I'm trying to use partial application of function arguments so I can use STL's find_if. Here is a sample program: (Class header and implementation is merged for brevity.) #include <functional> #include <iostream> #include <vector> #include <algorithm> #include <iostream> using namespace std; struct Odp { int id; Odp(int id) ...

How to get the position/dimensions of the open context menu on the desktop?

Hi, I have a utility that is opened from the context menu. You right-click an item in Windows Explorer and hit the "utility" button in the context menu to open the app. This brings up a little 'window' that's styled to be similar to a right click menu. Currently, it's really jarring to have that new menu open in a completely different p...

The Symbol file MyFile.pdb does not match the module

I've searched on this issue, and found many flavors and ideas but no real solutions. So, donning my asbestos suit and hoping for the best, I'm going to dare ask it again. I have managed C# code that calls managed C++ code, which in turn calls unmanaged C++ code. The unmanaged C++ code is throwing an exception, and I'd like to be able ...

Getting coords from Goocanvas::Points

I'm attempting to get the coordinates from an instance of Goocanvas::Points in goocanvasmm. I have this: double x = 0, y = 0; int i; Goocanvas::Points points; Glib::RefPtr<Goocanvas::Item> root = canvaswidget.get_root_item(); Glib::RefPtr<Goocanvas::Polyline> line = Goocanvas::Polyline::create(100, 100, 110, 120); root->add_child(line);...

operator= in subclass

Hi, I'm quite confused about how to solve the following problem (search both on SO and google didn't help much). Say we have a class defining basic operators and a simple vector as only data and add only additional methods in inherited classes: class Foo { public: // this only copies the data Foo& operator=(const F...

Ballistic curve problem

Ok i know this is quite off-topic for programmers but still I need this for app, so here it is: Ballistic curve (without wind or any other conditions) is specified by these 2 lines: So, there is a problem that you got 3 unknown values: x,y and time t, but only 2 equations. You can't really compute all 3 with just these values, I go...

convert epoch to time_t

I have a epoch in double and need to pass in to a function that takes time_t. How do I convert the epoch in double to time_t? I am on Linux with C++ code. Thanks. ...

C++: Partial template specialization

Hi, I'm not getting the partial template specialization. My class looks like this: template<typename tVector, int A> class DaubechiesWavelet : public AbstractWavelet<tVector> { // line 14 public: static inline const tVector waveletCoeff() { tVector result( 2*A ); tVector sc = scalingCoeff(); for(int i = 0; i < 2*A; ++i)...

Function overloading and inheritance

Possible Duplicate: Why does an overridden function in the derived class hide other overloads of the base class? I recently came across this interesting inheritance example - class FirstClass { public: void MethodA (int) { cout << "ONE\n";} void MethodA (int, int) { cout << "TWO\n";} }; class SecondClass : pu...

Iterators and multi-dimensional vectors?

So, I am trying to build a two-dimensional vector that will hold indexes for selecting tiles from a tileset. An iterator in one dimension is simple enough: std::vector<int> vec; std::vector<int>::iterator vec_it; for(int i=5; i>0; --i){ vec.push_back(i); } //prints "5 4 3 2 1 " for(vec_it = vec.begin(); vec_it != vec.end(); ++vec...

Using the "curiously recurring template pattern" in a multi-file program

Hello everyone, I'm a pretty novice (C++) programmer and have just discovered the CRTP for keeping count of objects belonging to a particular class. I implemented it like this: template <typename T> struct Counter { Counter(); virtual ~Counter(); static int count; }; template <typename T> Counter<T>::Counter() { ++...

Is any mainstream compiler likely to support C++0x unrestricted unions in the near future?

I keep looking, but it seems like there's zero interest from compiler developers in supporting these. To me, it seems odd - basically, current C++ has restrictions on unions that were always an irritation and never appropriate. You'd think that basically removing a few error checks would be a relatively simple way to tick an extra c++0x...

changes to a reference to an object don't affect the object itself

I have a class InventoryScreen that has a reference to another class GameData as a member, like this: class InventoryScreen { private: GameData& gameData; public: InventoryScreen(GameData& gd): gameData(gd) {} (...) }; class GameData { private: std::vector<Item> items; (...) }; In a member...

initializing char arrays in a way similar to initializing string literals

Suppose I've following initialization of a char array: char charArray[]={'h','e','l','l','o',' ','w','o','r','l','d'}; and I also have following initialization of a string literal: char stringLiteral[]="hello world"; The only difference between contents of first array and second string is that second string's got a null charact...

Fastest way to do many small, blind writes on a huge file (in C++)?

I have some very large (>4 GB) files containing (millions of) fixed-length binary records. I want to (efficiently) join them to records in other files by writing pointers (i.e. 64-bit record numbers) into those records at specific offsets. To elaborate, I have a pair of lists of (key, record number) tuples sorted by key for each join I ...