c++

List login sessions on a mac

I'm writing an application that runs as a system daemon (root session) for Mac OSX 10.6. As part of this application, I need to list all the active graphical login sessions. There is an (undocumented, but public) function called SessionGetInfo which will give me more information about a session with a known session Id, but I need a func...

Whats going on here can't you compare if(mychar1 == 'ä' || mychar2 == 'Ä') in C++?

Im trying to compare these two chars but on win 32 Visual Studio 2008: if(mychar1 == 'ä' || mychar2 == 'Ä') Erromess: Debug Assertion Failed! File:f\dd\vctools\crt_bld\self_x86\crt\src\xstring Line 1575 Expression: string subscript out of range ...

What are the differences between break and exit?

Even I used break() and exit() statements many times, I am bit confused between them. I need to know exact meaning of both, when we should use them. Please explain with small example. Thank you. ...

c++: Is it possible to #include inside a function body?

I want to include a header file only if a certain function body is called? Is this possible or recommended in C++? ...

Efficiency of iterators in unordered_map (C++)

I can't seem to find any information on this, so I turn to stackoverflow. How efficient are the iterators of std::tr1::unordered_map in C++? Especially compared to, say, list iterators. Would it make sense to make a wrapper class that also holds all the keys in a list to allow for efficient iteration (my code does use a lot of iterati...

Different RegisterWindowMessage() names appear the same

Using the C/C++ Windows API RegisterWindowMessage() I am using the name of the application as the message name. Next I call CreatMutex() using the same name so that I can tell if it already exists. If it does, I know this application is already running and not to launch a second instance of it. THis is the operation of my function Runn...

How to get statistical distributions out of C++ Code?

I want some help in programming a random generator for different types of distribution using C++ language. for the following: Geometric distribution Hypergeometric distribution Weibull distribution Rayleigh distribution Erlang distribution Gamma distribution Poisson distribution Thanks. ...

What's the purpose of having a separate "operator new[]" ?

Looks like operator new and operator new[] have exactly the same signature: void* operator new( size_t size ); void* operator new[]( size_t size ); and do exactly the same: either return a pointer to a big enough block of raw (not initialized in any way) memory or throw an exception. Also operator new is called internally when I crea...

C++ printf std::vector

How I can do something like this in C++: void my_print(format_string) { vector<string> data; //Fills vector printf(format_string, data); } my_print("%1$s - %2$s - %3$s"); my_print("%3$s - %2$s); I have not explained well before. The format string is entered by the application user. In C# this works: void my_print(format_s...

missing ';' before namespace when using boost 1.4.2

Working on moving some C++ code from Linux over to Windows. The code uses boost 1.4.2, however it keeps failing out on building the boost modules. Basically, every boost hpp file that happens to contain "namespace boost" errors with: error C2143: syntax error : missing ';' before 'namespace' Any idea what could be causing this? ...

Doxygen/C++: Global namespace in namespace list

Hi, Can I show the global namespace in the namespace list of the documentation generated with Doxygen? I have some functions which are extern "C", they appear in the documentation of the header file that declares them, but not in the namespace list and it gives the impression that they are not really there... ...

Getting libstdc++-v3/python

I am trying to download libstdc++-v3/python to enable pretty printing of stl containers. However, my provider returns: svn: Unknown hostname 'gcc.gnu.org' error. This is the command: svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python Is there an alternative way to get this package? ...

C++ app fails to initialize (0xc0000005), when using C# dll

Hi, I have a C# DLL, which I call from a native C++ programm. As I use Qt and /clr compiler option did not work I followed this tutorial for a bridge. So I have a VS2008 project (compiled with /clr), which links to the C# DLL and contains the bridge class and the native class, which exposes interfaces to my C++ programm. Another VS2008...

What's the simplest way of defining lexicographic comparison for elements of a class?

If I have a class that I want to be able to sort (ie support a less-than concept), and it has several data items such that I need to do lexicographic ordering then I need something like this: struct MyData { string surname; string forename; bool operator<(const MyData& other) const { return surname < other.surname || (surnam...

Why this friend function can't access a private member of the class?

I am getting the following error when I try to access bins private member of the GHistogram class from within the extractHistogram() implementation: error: 'QVector<double> MyNamespace::GHistogram::bins' is private error: within this context Where the 'within this context' error points to the extractHistogram() implementation. Does an...

Making Global Struct in C++ Program

Hello world! I am trying to make global structure, which will be seen from any part of the source code. I need it for my big Qt project, where some global variables needed. Here it is: 3 files (global.h, dialog.h & main.cpp). For compilation I use Visual Studio (Visual C++). global.h #ifndef GLOBAL_H_ #define GLOBAL_H_ typedef struc...

count of distinct acyclic paths from A[a,b] to A[c,d]?

I'm writing a sokoban solver for fun and practice, it uses a simple algorithm (something like BFS with a bit of difference). now i want to estimate its running time ( O and omega). but need to know how to calculate count of acyclic paths from a vertex to another in a network. actually I want an expression that calculates count of valid ...

Programming a VPN, Authontication stage - RFC not clear enough

I have a custom build of a Unix OS. My task: Adding an IPSec to the OS. I am working on Phase I, done sending the first 2 packets. What I am trying to do now is making the Identification Payload. I've been reading RFC 2409 (Apendix B) which discuss the keying materials (SKEYID, SKEYID_d, SKEYID_a, SKEYID_e and the IV making). Now, I ...

template typename question

Hi, I have a problem with template and wondering is there a possible way to achieve what I wanted to do. Here is my question. template <typename T> class A { public: typedef T* pointer; typedef const pointer const_pointer; A() {} template <typename D> A(const D& d) { // how can I st...

Socket throughput on localhost?

I've got an app that's using sockets to push data, and I'm currently testing it on my localhost (so that the sender and receiver are on the same computer). I'm seeing between 36 and 66MB/s of throughput, which seems somewhat slow to me. What are normal throughput ranges for binary data on a local socket connection? ...