c++

Switching to Linux for Windows development, bad idea?

I was contemplating switching to Linux for C++ development, coming from a Windows environment. Is this a bad idea? My workplace uses Windows and Visual Studio for our projects (some C# and java too, but right now I'm only developing in C++). If they decide to put me on a C# project, would development still possible (mono?)? What are the...

Networking Framework for C++ (UDP or TCP)?

I'm writing a threaded cross-platform application (Linux/Windows) using SDL and OpenGL, and to do networking I was considering SDL Net2 because it sits on top of SDL_Net. However, I've never done networking in C/C++ before, so I'm unfamiliar with any available cross-platform technologies. Is there anyone with experience with SDL_Net or ...

regular expression to split up searchphrase

I was hoping someone could help me writing a regex for c++ that matches words in a searchphrase, and explain it bit by bit for learning purposes. What I need is a regex that matches string within " " like "Hello you all", and single words that starts/ends with * like *ack / overfl*. For the quote part I have \"[\^\\s][\^\"]*\" but I c...

parser: parsing formulas in template files

I will first describe the problem and then what I currently look at, in terms of libraries. In my application, we have a set of variables that are always available. For example: TOTAL_ITEMS, PRICE, CONTRACTS, ETC (we have around 15 of them). A clients of the application would like to have certain calculations performed and displayed,...

What is a good scripting language to integrate into high-performance applications?

I'm a game's developer and am currently in the processing of writing a cross-platform, multi-threaded engine for our company. Arguably, one of the most powerful tools in a game engine is its scripting system, hence I'm on the hunt for a new scripting language to integrate into our engine (currently using a relatively basic in-house engin...

C++ Etiquette about Member Variables on the Heap

Is it considered bad manners/bad practice to explicitly place object members on the heap (via new)? I would think you might want to allow the client to choose the memory region to instantiate the object. I know there might be a situation where heap members might be acceptable. If you know a situation could you describe it please? ...

Template Function under GCC

Duplicate. See this. Can someone tell me why this does not compile under GCC? Both MSVC6, and VS2008 will compile it, with no warnings, even. The code... #include <iostream> #include <vector> #include <ctime> #include <cstdlib> using namespace std; template <typename T> T range(vector<T> &v) { vector<T>::iterator i = v.begin(); ...

Can you remove elements from a std::list while iterating through it?

I've got code that looks like this: for (std::list<item*>::iterator i=items.begin();i!=items.end();i++) { bool isActive = (*i)->update(); //if (!isActive) // items.remove(*i); //else other_code_involving(*i); } items.remove_if(CheckItemNotActive); I'd like remove inactive items immediately after update them, ...

Is it possible to get a char* name from a template type in C++

I want to get the string name (const char*) of a template type. Unfortunately I don't have access to RTTI. template< typename T > struct SomeClass { const char* GetClassName() const { return /* magic goes here */; } } So SomeClass<int> sc; sc.GetClassName(); // returns "int" Is this possible? I can't find a way and am about...

Good c++ lib for threading

I prefer a lib solely based on pthreads. What is a good c++ lib to for threading? ...

Simple C++ Threading

I am trying to create a thread in C++ (Win32) to run a simple method. I'm new to C++ threading, but very familiar with threading in C#. Here is some pseudo-code of what I am trying to do: static void MyMethod(int data) { RunStuff(data); } void RunStuff(int data) { //long running operation here } I want to to call RunStuff fro...

C++: difference between ampersand "&" and asterisk "*" in function/method declaration?

Is there some kind of subtle difference between those: void a1(float &b) { b=1; }; a1(b); and void a1(float *b) { (*b)=1; }; a1(&b); ? They both do the same (or so it seems from main() ), but the first one is obviously shorter, however most of the code I see uses second notation. Is there a difference? Maybe in case it's s...

Help me make this code exception-safe.

So I have this library code, see... class Thing { public: class Obj { public: static const int len = 16; explicit Obj(char *str) { strncpy(str_, str, len); } virtual void operator()() = 0; private: char str_[len]; }; explicit Thing(vector<Obj*> &o...

extend a abstract base class w/o source recompilation?

ignore this, i thought of a workaround involving header generation. It isnt the nicest solution but it works. This question is to weird to understand. Basically i want to call a virtual function that hasnt been declared in the lib or dll and use it as normal (but have it not implemented/empty func). I have an abstract base class in my ...

How to screen capture my program?

Duplicate: Best way to take screenshots of a window with c++ (windows) I have a Windows (2000/XP/Vista/W7) C++ desktop application that would like to save a screen capture of itself. It is an MFC dialog application. Can someone pass me a pointer that would get me on the road to implementing this feature? ...

__FILE__, __LINE__, and __FUNCTION__ usage in C++

Presuming that your C++ compiler supports them, is there any particular reason not to use __FILE__, __LINE__ and __FUNCTION__ for logging and debugging purposes? I'm primarily concerned with giving the user bad data due - for example, reporting the incorrect line number or function as a result of optimization - or taking a performance h...

Referencing a platform-specific library from a non-specific .NET app

I often need to include little bits of native code in my C# apps, which I tend to do via C++/CLI. Usually I just need to use a C++ library for which there exists no good alternative for .NET; but sometimes performance is a factor too. This is problematic; doing so means adding a reference to a specific x86 or x64 library. Most librari...

Windows GUI C++ Programming

I want to learn C++ GUI programming using Visual Studio 2008. I'm not sure where to start though. I learned C++ in high school, but not GUI. I've been doing C# for about 3 years now and thats how I "learned" GUI programming. Now I want to learn how to write GUI's without the use of the .NET framework, so where do I start? ...

File pointer behaviour ?

This is with reference to the question I asked earlier - What is the correct way to declare and use a FILE * pointer in C/C++? MyFile.h char sMsg[712] = ""; #define STD_MSG(string) \ fprintf (stderr, string) #define ERR_MSG(fp, string) \ fprintf (fp, "%s\n", string);\ fflush (fp) MyFile.C #include "PdmTestClnt.h" //---...

Trying to include iPhone OpenGLES headers in C++ code

I have some C++ doing OpenGL drawing and am trying to figure out how to include the opengl headers without it giving me thousands of errors in the obj-c code. ...