c++

minimal build dependency tree

Hello, I'm currently using an IDE which builds c++ projects for several platforms (win32, windows mobile, symbian etc). This IDE doesn't keep a build dependency list and simply rebuilds the entire project every time. This wastes a lot of our time, which made us consider implementing a smarter build process: cpp files will be recompiled o...

How to validate certification path against url

WARNNING: Total certificate newbie I have a certificate that is used for server authentication and I want to check if that certificate is validate for the url that the server is publish on. for example: if the certificate is for *.myserver.com then any url that its host part ends with myserver.com is valid. What I would like is some...

Comparison of arrays in google test?

I am looking to compare two arrays in google test. In UnitTest++ this is done through CHECK_ARRAY_EQUAL. How do you do it in google test? ...

determine value range of template type in C++

Hi, In a template function, I like to determine the range for the value of its template type. For specific type, like int, INT_MAX and INT_MIN are what I want. But how to do the same for a template type? Thanks and regards! ...

Windows Mobile Sockets SSL Communication library

I have a Win32 application that uses boost::asio and openssl library but it seems that they are not supported under WM, am I correct? Can anyone suggest WM API/library for WM Sockets, I need to connect to a server through SSL connection. Is the only option for me WinSocks + OpenSSL? ...

Why STL implementation is so unreadable? How C++ could have been improved here?

For instance why does most members in STL implementation have M or _ or __ prefix? Why there is so much boilerplate code ? What features C++ is lacking that would allow make vector (for instance) implementation clear and more concise? ...

C++ logical operators return value

Hi, Here is some code I'm writing in C++. There's a call to an addAVP() function dMessage.addAVP(AVP_DESTINATION_HOST, peer->getDestinationHost() || peer->getHost()); which has two versions: one overloaded in the second parameter to addAVP(int, char*) and another to addAVP(int, int). I find the C++ compiler I use calls the addAVP(int...

Symbian: clear buffer of RSocket object

Hi, I have to come back once again to sockets in Symbian. Code to set up a connection to a remote server looks as follows: TInetAddr serverAddr; TUint iPort=111; TRequestStatus iStatus; TSockXfrLength len; TInt res = iSocketSrv.Connect(); res = iSocket.Open(iSocketSrv,KAfInet,KSockStream, KProtocolInetTcp); res = iSocket.SetOpt(...

Are member variables of an object that is on the heap also automatically on the heap?

class A { public: A(); ~A(); int X; }; A::A() { X = 5; int Y = 4; } //..... in another file A * objectOnHeap = new A(); In this case, since "objectOnHeap" is on the heap, is X also on the heap even though it wasn't specifically new'd up? And in this case Y is allocated on the stack (and of course goes out of scope), correc...

Operator overloading (unary minus, in particular)

Hello, I need to implement the unary minus for a class. As the class is quite complicated, I must call the constructor in some way. If I try - ClassName ClassName::forUnaryMinus(){ ClassName retval(_parameters); //do stuff return retval; } The compiler complains - warning C4172: returning address of local variable or temp...

Where can I find source of unhook function used in STL implementation provided with g++.

It is used in /usr/include/c++/4.3/stl_list.h on my system (current Ubuntu). ...

std::vector reserve() and push_back() is faster than resize() and array index, why?

I was doing a quick performance test on a block of code void ConvertToFloat( const std::vector< short >& audioBlock, std::vector< float >& out ) { const float rcpShortMax = 1.0f / (float)SHRT_MAX; out.resize( audioBlock.size() ); for( size_t i = 0; i < audioBlock.size(); i++ ) { out[i] = (float...

Writing my own shell... stuck on pipes?

Hi guys, For the past few days I have been attempting to write my own shell implementation but I seem to have gotten stuck on getting pipes to work properly. I am able to parse a line and fork off the commands between the pipes (ex: ls | sort) individually but can't seem to get them to pipe input from one into the other. I think I jus...

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'Rectangle' (or there is no acceptable conversion)

im required to write a function to overload the ==operator to compare width, height and colour. i need to return 'Y' if its equal and 'N' if its not. this is my code which i think its correct but keeps getting the error in the title. i've done searches and nothing came close to comparing 3 data as most examples are for comparing 2 da...

string reverse in C++

I found this piece of code on the site, it seems the author is long gone, anyway, I'm having hard time understanding the actual swap and how the reverse occurs: void strrev2(char *str) { if( str == NULL ) return; char *end_ptr = &str[strlen(str) - 1]; char temp; while( end_ptr > str ) ...

Why are "long *" and "int *" not compatible in 32-bit code?

I was wondering why the following code doesn't compile: void foo_int(int *a) { } void foo_long(long *a) { } int main() { int i; long l; foo_long(&i); foo_int(&l); } I am using GCC, and neither calls work either in C or C++. Since it is a 32-bit system, both int and long are signed 32-bit integers (which can be verifi...

what is array decaying?

what is decaying of array? is there any relation to the array pointers? ...

How can I compare similar codebases?

We have several C++ projects that were built from the same codebase. There's a lot of similarities and common code between them but they were developed independently; source was not shared in any way. Classes and files will have been renamed even if the underlying code hasn't changed and individual lines will have been tweaked, changed a...

overloading operator<< for use with ostream

I am using CPPUnit to test a class in my program. This class (SCriterionVal) is somewhat unique because it has conversion operators for a lot of types (it's essentially a dynamic type value class). When I compile test cases that test it using CPPUNIT_ASSERT_EQUAL(), I get compilation errors about "operator<< is ambiguous" from one of t...

why does this work? (finding odd number in c++)

for (unsigned int i = 1; i <= 100; i++) { if (i & 0x00000001) { std::cout << i<<","; } } why does (and how): if( i & 0x00000001 ) figure out the odd number? ...