c++

How to Use CCache with CMake?

I would like to do the following: If CCache is present in PATH, use "ccache g++" for compilation, else use g++. I tried writing a small my-cmake script containing CC="ccache gcc" CXX="ccache g++" cmake $* but it does not seem to work (running make still does not use ccache; I checked this using CMAKE_VERBOSE_MAKEFILE on). Updat...

I am new to threads, What does this compile error mean?

Using C++. pthread_t threads[STORAGE]; // 0-99 ... void run() Error>>> int status = pthread_create(&threads[0], NULL, updateMessages, (void *) NULL); if (status != 0) { printf("pthread_create returned error code %d\n", status); exit(-1); } ... void ClientHandler::updateMessages(void *) { string reqUpdate = "91"; // Reques...

big integers in c++

I know this question has probably been asked in this forum many times and in the web as well. I am asked to create an implementation of a big integer in c++, however there is a constraint that one of my constructor should take an int as an argument... so I am guessing there will be more than one non-default constructor... so my question ...

Passing void(*) in C++

I have a std::map which I'm trying to store void pointers for the values. The problem is, most of the pointer I'm trying to store are methods in a class and have different amount of params. I know for the params I can use a va list so thats not too much of a problem, the problem would be the actual pointer itself. This is what I have: ...

Const correctness in C++ operator overloading returns

Hi! I'm a little confused as to why I've been told to return const foo from a binary operator in c++ instead of just foo. I've been reading Bruce Eckel's "Thinking in C++", and in the chapter on operator overloading, he says that "by making the return value [of an over-loading binary operator] const, you state that only a const member f...

Ensuring a file is flushed when file created in external process (Win32)

Hi all, Windows Win32 C++ question about flushing file activity to disk. I have an external application (ran using CreateProcess) which does some file creation. i.e., when it returns it will have created a file with some content. How can I ensure that the file the process created was really flushed to disk, before I proceed? By this ...

Download an Image file from web server using VC++ 9.0

I want to code a VC++ 9 based console application which downloads an image from a webserver. I have code which used to run in VC++ 6, but its giving lot of compilation errors in VC++ 9.0. I need code which compiles in VC++ 9.0 using MS Visual Studio 2008. Also I need only win32 code and not MFC. ...

Reading/Writing Magnetic Striped ID Cards in Linux

How would I accomplish this? Is there a specific brand of card reader/writer that works easily with linux and windows (linux being more important as I need to deploy these to cheap kiosks). ...

big integers with fixed length

I am looking for a library for big integers but with fixed width (128 or 256 would be enough). The reason is I don't want any allocation on the heap. I tried to make them myself but implementing multiplication, division and modulo an efficient way seems to be quite a pain. Does this already exists somewhere ? Thanks ...

textureMappingu/v in common Vertex structures?

Looking through some directx examples, I'm often seeing the structure for a vertex to be defined as such: struct Vertex { vector position; vector normal; int textureMappingu; int textureMappingv; } Under this type of vertex, what are textureMappingu/v for? ...

Reading directly from an std::istream into an std::string

Is there anyway to read a known number of bytes, directly into an std::string, without creating a temporary buffer to do so? eg currently I can do it by boost::uint16_t len; is.read((char*)&len, 2); char *tmpStr = new char[len]; is.read(tmpStr, len); std::string str(tmpStr, len); delete[] tmpStr; ...

How can I do an HTTP redirect in C++

I'm making an HTTP server in c++, I notice that the way apache works is if you request a directory without adding a forward slash at the end, firefox still somehow knows that it's a directory you are requesting (which seems impossible for firefox to do, which is why I'm assuming apache is doing a redirect). Is that assumption right? ...

QT Webkit & OpenGL Rendering Context

Would it be possible to create a window with a webpage using a webkit component using QT4, then embed an OpenGL context into the middle in the same way a java applet or a flash applet may appear normally? ...

Are there any CURL alternatives for C++?

I hate CURL it is too bulky with too many dependencies when all I need to do is quickly open a URL. I don't even need to retrieve the contents of the web page, I just need to make the GET HTTP request to the server. What's the most minimal way I can do this and don't say CURL !@#$ ...

Creating custom message types in win32?

Is there a way to define and send custom message types in Win32, to be caught by your Main message handler? For example, my main message handler captures messages such as WM_PAINT, WM_RESIZE, WM_LBUTTONDOWN etc. Can I create my own WM_DOSOMETHING? If so, how would I send this message? Ah, I actually just discovered this was asked before...

Valgrind memcheck programmatic enable

I don't suppose there is a way to programmatically enable/disable Valgrind memcheck the way you can with callgrind? (Start/stop instrumentation). It's painfully, unusably slow (which is okay if the code you want to test starts automatically and you just leave it running), but I can't actually get into the code that's important without c...

Initialization: T x(value) vs. T x = value when value is of type T

T x(value) is usually the better choice because it will directly initialize x with value, whereas T x = value might create a temporary depending on the type of value. In the special case where value is of type T though, my guess is that the expression T x = value will always result in exactly one copy constructor call. Am I correct? I'v...

Where does C++ standard define the value range of float types?

As far as I know floating point values are of the form n * 2^e, with float range being n = -(2^23-1) - (2^23-1), and e = -126 - 127, double range being n = -(2^52-1) - (2^52-1), and e = -1022 - 1023 I was looking through the C++ standard, but failed to find the place where the standard specifies this, or mandates the association of t...

printing ip addresses using gdb

I am debugging a networking code and want to print ip addresses which are declared as int32. when i print it using gdb print command, i get some values which is not much meaningful. How can i possibly print them in meaningful format? ...

Sun C++ Compilers and Boost

I am currently developing on OpenSolaris 2009-06. The Boost::MPL Documentation seems to suggest that sun compilers are not supported (the document was last updated in 2004 ). Boost's top level documentation seems to suggest that the sun compilers 5.10 onwards are supported -- I guess this is a general level of support or does this includ...