c++

Anyone have experience with LLVM?

Does anyone have experience with LLVM, llvm-gcc, or Clang? The whole idea behind llvm seems very intriguing to me and I'm interested in seeing how it performs. I just don't want to dump a whole lot of time into trying the tools out if the tools are not ready for production. If you have experience with the tools, what do you think of t...

Best 2D animation library/tech for "iPhone" style animation on WIN32?

All, I have built a nifty demo application that displays data about our internal systems as a full-screen "billboard" style display. You could think of this as something like an application displaying the national deficit - rapidly increasing numbers, animating very quickly, all day. The problem is that the demo works really well and t...

Getting started with mobile programming. What is a good platform ?

What is a good mobile programming platform to go with for a c++ developer? Is learning android a good option? ...

How do you free a wrapped C++ object when associated Javascript object is garbage collected in V8?

V8's documentation explains how to create a Javascript object that wraps a C++ object. The Javascript object holds on to a pointer to a C++ object instance. My question is, let's say you create the C++ object on the heap, how can you get a notification when the Javascript object is collected by the gc, so you can free the heap allocated ...

How do you deal with large dependencies in Boost?

Boost is a very large library with many inter-dependencies -- which also takes a long time to compile (which for me slows down our CruiseControl response time). The only parts of boost I use are boost::regex and boost::format. Is there an easy way to extract only the parts of boost necessary for a particular boost sub-library to make c...

Is there a portable equivalent to DebugBreak()/__debugbreak?

In MSVC, DebugBreak() or __debugbreak cause a debugger to break. On x86 it is equivalent to writing "_asm int 3", on x64 it is something different. When compiling with gcc (or any other standard compiler) I want to do a break into debugger, too. Is there a platform independent function or intrinsic? I saw the XCode question about that, b...

String literals inside functions: automatic variables or allocated in heap?

Are the string literals we use inside functions automatic variables? Or are they allocated in heap which we have to free manually? I've a situation like the code shown below wherein I'm assigning a string literal to a private field of the class (marked as ONE in the code) and retrieving it much later in my program and using it (marked a...

What ways are there of drawing 3D trees using Java and OpenGL?

I know how to draw basic objects using JOGL or LWJGL to connect to OpenGL. What I would like is something that can generate some kind of geometry for trees, similar to what SpeedTree is famous for. Obviously I don't expect the same quality as SpeedTree. I want the trees to not look repetitive. Speed is not a concern, I do not expect to ...

How to I get the function name while in a function for debug strings?

I want to output the function name each time it is called, I can easily copy and paste the function name, however I wondered if there was a shortcut that would do the job for me? At the moment I am doing: SlideInfoHeader* lynxThreeFile::readSlideInfoHeader(QDataStream & in) { qDebug("lynxThreeFile::readSlideInfoHeader"); } but wh...

Why can't c++ ifstreams read from devices?

I knew I should never have started using c++ io, the whole "type safety" argument is a red herring (does anyone really find that it's one of their most pressing problems?). Anyhow, I did, and discovered a strange difference between ifstreams and FILE*s and plain old file descriptors: ifstreams cannot read from a device. Can anyone think ...

Incorporating shareware restrictions in C++ software.

I wish to implement my software on a shareware basis, so that the user is given a maximum trial period of (say) 30 days with which to try out the software. On purchase I intend the user to be given a randomly-generated key, which when entered enables the software again. I've never been down this route before, so any advice or feedback o...

What is the most efficient way to (re)initialise a vector to a certain length with initial values

Hi all, As a function argument I get a vector<double>& vec (an output vector, hence non-const) with unknown length and values. I want to initialise this vector to a specific length n with all zeroes. This will work vec.clear(); vec.resize( n, 0.0 ); And this will work as well: vec.resize( n ); vec.assign( n, 0.0 ); Is the second...

linker out of memory LNK1102

My colleagues and I have tried to build a project containing several thousand classes , but we're getting a LNK1102 error ( Linker out of memory ) . I've seen several tips on the internet , such as increasing the virtual memory . We tried but this didn't help . We've also seen some as enabling different warning levels when compiling the ...

Forcing single-argument constructors to be explicit in C++?

By default, in C++, a single-argument constructor can be used as an implicit conversion operator. This can be suppressed by marking the constructor as explicit. I'd prefer to make "explicit" be the default, so that the compiler cannot silently use these constructors for conversion. Is there a way to do this in standard C++? Failing tha...

To STL or !STL, that is the question...

Unquestionably, I would choose to use the STL for most C++ programming projects. The question was presented to me recently however, "Are there any cases where you wouldn't use the STL?"... The more I thought about it, the more I realized that perhaps there SHOULD be cases where I choose not to use the STL... For example, a really large,...

Cross platform format string for variables of type size_t?

On a cross platform c/c++ project (Win32, Linux, OSX), I need to use the *printf functions to print some variables of type size_t. In some environments size_t's are 8 bytes and on others they are 4. On glibc I have %zd, and on Win32 I can use %Id. Is there an elegant way to handle this? ...

Learning game programming

Quick question: I've been in the web-dev world for several years now, I've wrapped my head around Java, Python, PHP, C# and Ruby- and currently make my living as a C#.NET programmer and I want to learn game development for real, no "build your own 2d sprite game over 14 days"-bs, the real deal. Where do I start? learning C? learning C++?...

What is the most spectacular way to shoot yourself in the foot with C++?

In 1986 or so, Bjarne Stroustrup famously said: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." What is, in your opinion, the most spectacular way to blow your leg off in C++? Points for originality, and for helpfulness. ...

C++ thread/process identifier

Is there a portable way of getting thread and/or process identifier (string, int, ...) with C++? ...

Which is more appropriate: getters and setters or functions?

Is it ever appropriate to abandon the "getMyValue()" and "setMyValue()" pattern of getters and setters if alternative function names make the API more obvious? For example, imagine I have this class in C++: public class SomeClass { private: bool mIsVisible; public: void draw(); void erase(); } I could add functions to g...