c++

std::endl is of unknown type when overloading operator<<

I overloaded operator << template <Typename T> UIStream& operator<<(const T); UIStream my_stream; my_stream << 10 << " heads"; Works but: my_stream << endl; Gives compilation error: error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'UIStream' (or there is no acceptable conversion) What is ...

Sockets: How to send data to the client without 'waiting' on them as they receive/parse it

I have a socket server, written in C++ using boost::asio, and I'm sending data to a client. The server sends the data out in chunks, and the client parses each chunk as it receives it. Both are pretty much single threaded right now. What design should I use on the server to ensure that the server is just writing out the data as fast...

C++ pointer issue

Hi everyone, So I'm learning C++ at the moment and I'm trying to work things out with pointers. Could anybody explain the following scenario: bool testFalse = false; //testFalse = false bool *thisIsFalse = &testFalse; //value of address of thisIsFalse shows that the address contains false bool shouldBeFalse = &thisIsFalse; //shouldBeF...

Distribute a application to the public so they can compile, without revealing the source

I have a proprietary application I would like to hand out to a few people for testing, except we do not want to reveal the source to them. The application is written in C++ for Linux. It links against readily available packages on the Fedora/Ubuntu repos. Is there any way to process the source to something intermediate... then distribu...

Reading/Understanding third-party code

When you get a third-party library (c, c++), open-source (LGPL say), that does not have good documentation, what is the best way to go about understanding it to be able to integrate into your application? The library usually has some example programs and I end up walking through the code using gdb. Any other suggestions/best-practicies?...

Achieving Interface functionality in C++

A big reason why I use OOP is to create code that is easily reusable. For that purpose Java style interfaces are perfect. However, when dealing with C++ I really can't achieve any sort of functionality like interfaces... at least not with ease. I know about pure virtual base classes, but what really ticks me off is that they force me in...

WriteProcessMemory to SYSTEM process with SeDebugPrivilege enabled. (C, Vista)

Hi, I'm interested in injecting DLLs into SYSTEM owned processes on my Vista machine. I'm going about this using the traditional method of VirtualAllocEx, WriteProcessMemory and CreateRemoteThread. However, because this will be operating on SYSTEM processes, I enable SeDebugPivilege on the injecting process before opening the target pro...

Porting to Solaris SPARC using Sun Studio 12

I am trying to compile an object file using the code below. //--Begin test.cpp class A; void (A::* f_ptr) (); void test() { A *a; (a->*f_ptr)(); } //-- End test.cpp For GNU g++ compiler, it is able to compile the object file. $ g++ -c test.cpp But for Sun Studio 12 on a Solaris 10 (SPARC), it outputs an error. $ CC -c tes...

Getting a key (secret) for a HMAC-MD5 hash

I am looking at the NetUserSetInfo method. It can take a USER_INFO_21 structure that allows me to pass in a "one-way encrypted LAN Manager 2.x-compatible password". I think this means a HMAC-MD5 hash. The class System.Security.Cryptography.HMACMD5 can create one of these hashes, but it needs a key (or shared secret) for that class to ...

serial communication anomaly in Linux?

Hi all, I am using select call to communicate with an external subsystem (protocol for the same has been provided and implemented as a Qt thread) using serial port RS232. We do not have the hardware for the external systems and thus we have developed in house simulators using .Net 2.0 and C# to mimic the behavior of the underlying subsy...

Pointer to Value in a std::map

Hi, I have a std::map that is used by multiple threads to store data. The map is declared like this: std::map<int, Call> calls; From each thread, I have to acquire a mutex lock, obtain a pointer or reference to the object belonging to that thread, then release the mutex lock. I can modify the object after that because each object is ...

CreateProcess doesn't pass command line arguments

Hello I have the following code but it isn't working as expected, can't figure out what the problem is. Basically, I'm executing a process (a .NET process) and passing it command line arguments, it is executed successfully by CreateProcess() but CreateProcess() isn't passing the command line arguments What am I doing wrong here?? int ...

Escaping a # symbol in a #define macro?

OK, without going into the gory details I want to use a #define macro that will expand to a #include but the '#' sign is confusing the preprocessor (as it thinks I want to quote an argument.) For example, I want to do something like this: #define MACRO(name) #include "name##foo" And use it thus: MACRO(Test) Which will expand to: ...

C++ multiline string literal

Is there any way to have multiline plaintext constant literals in C++, ala Perl? Maybe some parsing trick with #includeing a file? I can't think of one, but boy, that would be nice. I know it'll be in C++0x. ...

Windows message loop

Theres some reason for this code not reach the first else? I got it exactly the same from vairous sources. Than I did my own encapsulation. Everything goes fine. Window is created, messages are treated, events are generated to keyborad input in the client area, the gl canvas works fine (when I force it to draw). The only problem is that...

Simple pthread! C++

I have no idea why this dosent work #include <iostream> #include <pthread.h> using namespace std; void *print_message(){ cout << "Threading\n"; } int main() { pthread_t t1; pthread_create(&t1, NULL, &print_message, NULL); cout << "Hello"; return 0; } Error: [Description, Resource, Path, Location, Type] init...

Maven-like dependency management for C++?

Say I have a C++ project that is split in several subprojects. The subproject all produce a DLL and different teams of developers work on each of the subproject. Now if I want to build the main project, is there a way to avoid having to build all the subprojects by myself? In short, I'm looking for something that does the dependency man...

creating a vector of pointers that point to more vectors

Hello, I am trying to create a vector that contains pointers, each pointer points to another vector of a type Cell which I have made using a struct. The for loop below allows me to let the user define how many elements there are in the vector of pointers. Here's my code: vector< vector<Cell>* > vEstore(selection); for (int t=0; t<selec...

How to call Base class method through base class pointer pointing to derived class

class Base { public: virtual void foo() {} }; class Derived: public Base { public: virtual void foo() {} }; int main() { Base *pBase = NULL; Base objBase; Derived objDerived; pBase = &objDerived; pBase->foo(); /*Here Derived class foo will be called, but i want this to call a base clas...

Adding generic logging support in C++ shared library

I'm writing a c++ shared library that is intended to be used by other library or executable. What is the best way to add a generic logging in my library? Ideally I'd like to adapt my library to logging functionality chosen by the library's user. Suppose i have a class in my library class A { public: void method(string param1, in...