c++

Comparison of C++ STL collections and C# collections?

I'm still learning C# and was surprised to find out that a List<T> is much more like a std::vector than a std::list. Can someone describe all the C# collections in terms of the STL (or if STL comparisons are difficult, standard conceptual data types with Wikipedia links? I expect the reference would be widely useful. A minimal list of...

GCC Reducing Binary Bloat -- Strange Side Effect

The Weirdness I have compiled Google Protocol Buffers using no extra parameters for a "bloat" compile, and compile with the following command ./configure CXXFLAGS="-ffunction-sections -fdata-sections". a du-h reveals: 120K ./bloat/bin 124K ./bloat/include/google/protobuf/io 8.0K ./bloat/include/google/protobuf/compiler/java 12K ./bloat...

Quick look up of Data structures.

Hi, can i get the link to Quick look up of data structures.. ...

Visual C++ 2008: debugging data behind pointer array

How can I see data behind a pointer to an array more than the first item in Visual Studio 2008? It would be so useful to see arbitrary amount of items, not just the first one. ...

How to interrupt select/pselect running in QThread

I have a QThread that reads from a socket and sends a signal (QT signal) when there are any data available. This would be easy with blocking read(2), but i need to be able to stop the thread from outside without waiting for too long. If I were using pthread I would use pselect and pthread_kill(thread_id, some_signal), but QThread doesn'...

trouble using unmanaged c++ from c# using dllimport

Hi guys, i am having trouble importing c++ unmanaged dll into C# [winform]. Can someone help? Basically i am just trying to create a safearray of strings in c++ and trying to send it to C#. Here is my c++ code. extern "C" __declspec(dllexport) BOOL GetStringArr(SAFEARRAY* arr) { SAFEARRAY* myArray; SAFEARRAYBOUND rgsabound[1]; ...

I don't seem to understand the output of this program regarding conversion of integer pointer to character pointer

In the program below i initiliaze i to 255 Thus in Binary we have: 0000 0000 1111 1111 That is in Hex: 0x 0 0 f f So according to Little-Endian layout: The Lower Order Byte - 0xff is stored first. #include<cstdio> int main() { int i=0x00ff; //I know 0xff works. Just tried to make it understable char *cptr=(char *)&i; ...

Any reason to use a run-time assert instead of compile-time assert?

While reviewing Visual C++ codebase I found a following strange thing. A run-time assert (which is check the condition and throw an exception if the condition is violated) was used in a case when the condition could be evaluated at compile time: assert( sizeof( SomeType ) == sizeof( SomeOtherType ) ); clearly the compiler will evaluat...

compare and swap vs test and set

Could someone explain to me the working and differences of above operations in multi-threading? ...

Get Lua state from inside Lua so it can be passed back to C.

I am able to load a DLL created from C source from within Lua. So what I want to be able to do is pass the current Lua state FROM Lua to the loaded DLL. Basically I'm using a game engine that uses Lua. The scene editor of said game engine creates the Lua state and calls Lua scripts and I know for a fact that it uses 1 lua state for all...

How to use curlpp's InfoGetter?

I'm using curlpp in an application and need to get the URL I was redirected to. Apparently there are two ways: track the Location headers (ugly) or use curlpp::InfoGetter (the c++ counterpart of curl_easy_getinfo()). But how do I use curlpp::InfoGetter? I cant't find any examples. Does anyone have a short snippet? ...

Extending enum in derived classes.

I have a class hierarchy, and each class in it has an exception class, derived in a parallel hierarchy, thus... class Base { }; class Derived : public Base { }; class BaseException : public std::exception { enum {THIS_REASON, THAT_REASON}; }; class DerivedException : public BaseException { // er...what? }; I would like, in t...

Recommendation on big integer calculation library.

Could your recommend some good big integer calculation library in C/C++/Java and it is better to support logarithmetic. Thanks. ...

Continous integration build tool for CVS version control system with C++ and C# projects

Hi, I want to implement a continuous integration build system for a client. There source code is mainly c++ and .NET with a bit of JAVA. They use CVS for version control system as well as VSS for some other projects (i know, its old fashioned.. but hey they are not ready to make the change.) So i would like to know what your thought...

How do I use the 7z sdk to extract rar/zip files (C++)?

I'm trying to write a small, cross-platform comic book reader (Qt / C++). I don't care what's already out there, I know there are some. My problem is that I need to read the comic book formats, which are renamed rar and zip files. The documentation is very... nonexistent? There's no "hello archive" document anywho. How can I set this u...

Can I cause a compile error on "too few initializers"?

I am using an aggregate initializer to set up a block of static data for a unit test. I would like to use the array size as the expected number of elements, but this can fail if too few initializers are provided: my_struct_type expected[14] = { { 1.234, 0, 'c' }, { 3.141, 1, 'z' }, { 2.718, 0, 'a' } }; This gives no compi...

Creating dynamically sized objects

Removed the C tag, seeing as that was causing some confusion (it shouldn't have been there to begin with; sorry for any inconvenience there. C answer as still welcome though :) In a few things I've done, I've found the need to create objects that have a dynamic size and a static size, where the static part is your basic object members, ...

Merge two STL vectors with an alternation pattern

I have two STL vectors A and B and need to merge them into a third one, where the elements should be ordered in a way, that every nth element in the output vector should be of vector B. My current code looks something like this: std::vector<int> a(10, 4); std::vector<int> b(10, 8); std::vector<int> c; static const std::size_t STEP(3); ...

Generate Windows Compatible Binary from Xcode C++ Console Application

Hi All, I am using XCode for developing a C++ Console Application. After compiling XCode generates the Unix Executable File, which run on Mac perfectly. But doesn't work on windows. I have tried changing the active architecture as well from x86_64 to i386 but no luck. Is it possible anyway to generate executable like Borland C, or Turb...

C++ - basic thread question

Hello! I have a simple threading question - how should the following be synchronized? I have main thread and a secondary thread that does something only once and something - more that once. Basically: Secondary thread: { Do_Something_Once(); while (not_important_condition) { Do_Something_Inside_Loop(); } } I want t...