c++

Is there a way to get better information for the context of an error when using msvc? (ex: C2248)

Hi, I'm wondering if there is a way to get better information about the location of an error in msvc (2005)? Exemple, when inheriting from boost::noncopyable in my class I get a C2248 error saying something like: error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::nonc...

A way to turn boost::posix_time::ptime into an __int64

Does anyone know if there is a good way to turn a boost::posix_time::ptime into an __int64 value. (I have compiled the microsecond version, not the nanosecond version). I need to do this somehow as I am looking to store the resulting __int64 in a union type which uses the raw data for a high-performance application. Some type of Memen...

g++ doesn't like template method chaining on template var?

I'm trying to compile with g++ some code previously developed under Visual C++ 2008 Express Edition, and it looks like g++ won't let me call a template method on a reference returned by a method of a template variable. I was able to narrow the problem down to the following code: class Inner { public: template<typename T> T get() con...

Is it possible to hijack standard out

I am trying to redirect the stdout of an already running process on Windows XP using C#. I am aware that I can do this if I spawn the process myself, but for this application I would prefer a "listener" i could just attach to another process. Is this possible in pure .Net and if not is it even possible with Win32? Thanks UPDATE: There...

Specify the name of compiled binary (*.exe) within source code in Visual Studio 2008

From this thread http://www.codeguru.com/forum/showthread.php?p=1863547 It seems this cannot be done with: #pragma comment(linker, "/out:mycool.exe") Is there some simple way this can be done without having to use project settings, make files etc? Added: Why do I want to do this. Well this gets into another subject which is probab...

C++ map object not growing when members added

Below the map 'widgets' is always size of 1 for some reason. There should be 4 when it's done. Output: Widget: widget_ram_label:layout_bar:0 1 Widget: widget_ram_active:layout_bar:0 1 Widget: widget_ram_total:layout_bar:0 1 Widget: widget_wlan0_label:layout_bar:0 1 Here's widgets: std::map<const char *, Widget *> widgets; And here...

Removing from a HashTable C++

How do u remove from an array based hashtable? I need to prepare to remove several symbols from my table. If i dump what I want to delete in an character array of a fixed size, how would find the ones i would "potentially" delete? bool hashmap::get(char const * const symbol, stock& s) const { int hashVal = this->hashStr( symbol ); ...

Direct3D Texture Post-Processing/Copying

So I'm trying to implement some Direct3D post-processing, and I'm having issues rendering to textures. Basically, my program looks like this: // Render scene to "scene_texture" (an HDR texture)... ... device->SetRenderTarget(0, brightpass_surface); device->SetTexture(0, scene_texture); // Render "scene_texture" to "brightpass_texture...

why = operator works on structs without having been defined?

lets put a simple example: struct some_struct { std::string str; int a, b, c; } some_struct abc, abc_copy; abc.str = "some text"; abc.a = 1; abc.b = 2; abc.c = 3; abc_copy = abc; then abc_copy is an exact copy of abc.. how is it possible without defining the = operator? (this took me by surprise when working on some code..) ...

Using a std::set in a class?

I am trying to combine using a std::set and a class, like this: #include <set> class cmdline { public: cmdline(); ~cmdline(); private: set<int> flags; // this is line 14 }; but, it doesn't like the set flags; part: cmdline.hpp:14: error: ISO C++ forbids declaration of 'set' with no type cmdline.hpp:1...

How to deal with seniors' bad coding style/practices?

I am new to work but the company I work in hires a lot of non-comp-science people who are smart enough to get the work done (complex) but lack the style and practices that should help other people read their code. For example they adopt C++ but still use C-like 3 page functions which drives new folks nuts when they try to read that. Als...

Linux's Windows Filtering Platform equivalent?

Hi, More than once I picked myself wanting to have an easy way to edit packets on-the-fly in my LAN, so I thought it was time for me to make some "machinery" to do the job. I think WFP would do exactly what I needed. Not only I wanted to filter and edit packets off the computer my program would be running, but I would also like to ARP ...

Is there a cross-platform exec in Boost?

I want to execute a sub-process in C++. I need it to work on Windows and Linux. Is there such a function in Boost? What is the standard way of doing it? ...

std::string and format string

I found the below code through Google. It almost does what I want it to do, except it doesn't provide a way to indicate the precision like '%.*f' does in C-type format strings. Also, it doesn't provide anything further than 5 decimal places. Am I going to have to stick with C strings and snprintf? #include <string> #include <sstream> #i...

C++ Abstract base class array of ptrs to ptrs

I have an abstract base class (Comparable) with Date and Time virtually inheriting from it and a DateTime class v-inheriting from Date and Time. My problem is this: I was tasked with dynamically allocating an array of Comparables. Comparable ** compArray; compArray = new Comparable *[n]; // where n is user specified number of elements ...

Including header file with global variable

I need to include a header file that contains some global variables (not mine so I cannot change it). How do I do this so that the variables within the included file are considered 'extern' in all but one case? ...

Python callback with SWIG wrapped type

I'm trying to add a python callback to a C++ library as illustrated: template<typename T> void doCallback(shared_ptr<T> data) { PyObject* pyfunc; //I have this already PyObject* args = Py_BuildValue("(O)", data); PyEval_CallObject(pyfunc,args); } This fails because data hasn't gone through swig, and isn't a PyObject. I tried...

Embedding Ruby in a C++ application using SWIG?

I've successfully created Ruby-C++ bindings in the past using SWIG where the C++ code was compiled as a dynamic library with the Ruby script connecting to it. However, I'd like to do it the other way around. Create an executable using C++ and enable it to load and execute Ruby code. Ruby should be able to call functions defined on the C...

Using a pure C++ compiler versus Visual C++

Hello all. I searched around for the answers to these questions, but I have had little luck. So, I thought I would post them here to get some clarification. If this is a duplicate, please let me know, and I will close this. Okay, with that said, I would like to begin learning C++. I come from a C# background and I have a great respe...

Deallocating inheritance, C++

ostream& operator<<(ostream& out, const hashmap& h) { const char *getSymbol = NULL; h.hashTable->displayHeaders(out); for ( int hashIndex = 0; hashIndex < maxSize; hashIndex++ ) { getSymbol = h.hashTable[hashIndex].getSymbol(); if ( getSymbol ) { out << h.hashTable[hashIndex]; } } return out; } ...