c++

int to std::string?

I have following code: Tools::Logger.Log(string(GetLastError()), Error); GetLastError() returns a DWORD a numeric value, but the constructor of std::string doesnt accept a DWORD. What can I do? thanks in advance ...

Build Boost on Mac with Xcode...

Hi everyone! I've recently got acquainted with Boost library and I'd like to use it in my Xcode project. But sadly there is no HowTo or FAQ on how to do it :( What's the sequence of actions to build and use Boost libraries in Xcode? Thanks in advance :) ...

What standard does this "ISOTIME" structure represent?

In our code, we have a 16-byte packed struct that we call "ISOTIME": typedef struct isotime { struct { uint16_t iso_zone : 12; // corresponding time zone uint16_t iso_type : 4; // type of iso date } iso_fmt; int16_t iso_year; // year uint8_t iso_month; // month uint8_t iso_day; // day uint8_t iso...

Win32 function for scheduled tasks in C++

I have a function in C++ that needs to be called after a period of time and this task is repeated. Do you know any built-in function or sample code in Win32 or pthread? Thanks, Julian ...

saving file to network

I have a file that's about 7 MB that saves to my local share in a matter of seconds. However, saving that file to a network location takes minutes. I'm wondering what I can do to speed this up. Here are my current options: Save the data to a temporary file on the local machine, then copy the temporary file over to the network path. ...

Why am I getting segfaults randomly?

This is quite strange for me, but I'm getting an unexpected and random segmentation fault when I launch my program. Some times it works, some times it crashes.. The debugger of Dev-C++ points me to a line of the file : stl_construct.h /** * @if maint * Constructs an object in existing memory by invoking an allocated * object's ...

C++ destructors question

With regards to the sample code below, why is the destructor for the base class called twice? class Base { public: Base() { std::cout << "Base::Base()" << std::endl; } ~Base() { std::cout << "Base::~Base()" << std::endl; } }; class Derived : public Base { public: Derived() { std::cout << "Derived::...

unix domain stream sockets sending more data then it should be

I have two simple programs set up that share data through a unix domain socket. One program reads data out of a Queue and sends it to the other application. Before it is sent each piece of data is front-appended by four bytes with the length, if it is less then four bytes the left over bytes are the '^' symbol. The client application t...

Synchronized value between C# and C++?

Is there a function which exists in both C# and (unmanaged) C++ which returns a synchronized number (such as float or int)? For example is there something which brings the exact system time to at least the second which would return the exact same result on both C++ and C# is called in the exact same time? Just wondering really =) ...

Small, portable web browser library?

I am looking for a small and portable web browser to embed into my 3D engine. Basically, I need something small and fast that can render into a graphical buffer and take my input for links and stuff. It would be great if it could do JS as well. So far I've looked at Gecko and Webkit and Webkit is the winner so far (Gecko is way too huge...

determing access type of member variables of a class

Would following the table below be the best way of determining the access type of member variables of a class that I'm creating (sorry if this table is hard to see; it's the same table shown http://www.cplusplus.com/doc/tutorial/inheritance/)? Access public protected private members of the same class yes...

Inverse of A*X MOD (2^N)-1

Given a function y = f(A,X): unsigned long F(unsigned long A, unsigned long x) { return ((unsigned long long)A*X)%4294967295; } How would I find the inverse function x = g(A,y) such that x = g(A, f(A,x)) for all values of 'x'? If f() isn't invertible for all values of 'x', what's the closest to an inverse? (F is an obsolete...

DevC++ (Mingw) Stack Limit

Is it possible to set the stack limit in DevC++? Basically the same as "ulimit -s" would do on linux. ...

Is it possible to add an item to the right-click context menu of a Mac OS programmatically?

I have a program that works with a variety of files on both the Windows and Mac OS. I would like to give the user the option of adding a new option to their right click/control click context menu to the effect of "Compress with [Name of App]". I know this is quite possible in Windows with modifications to the registry, but is there a w...

How to differentiate (when overloading) between prefix and postfix forms of operator++? (C++)

Becuase I've overloaded the operator++ for an iterator class template typename list::iterator& list::iterator::operator++() { //stuff } But when I try to do list::iterator IT; IT++; I get a warning about there being no postifx ++, using prefix form. How can I specifically overload the prefix/postifx forms? ...

Why do I get an "Unreferenced Local Variable" warning? (C++)

When I do something like #include<iostream> int main() { int x; return 0; } I get a warning about x being an unreferenced local variable (I assume becuase I created a variable, then did not use it), why does this give me a warning though? ...

How to list Context/Apartments for COM Object?

I am using the vs2008 debbuger for a c++ project that uses COM objects of a .NET assembly. I am getting a 'DisconnectedContext' message from the managed debbuging assistant, but i can't figure out which of the pointer is holding a reference to a bad COM object. Is it possible to keep track of the appartment/context in a thread with visu...

How does <iostream> work? (C++)

Just out of curiosity, how does iostream access the input-output system. (I have a bad habit of constantly reinventing the wheel, and I'm wondering if I can build a custom input-output system to the likes of iostream). ...

Dynamic source code in C++

How to process dynamic source code in C++? Is it possible to use something like eval("foo")? I have some functions that need to be called depending on user's choice: void function1 (); void function2 (); ... void functionN (); int main (int argv, char * argv []) { char * myString = new char [100]...

Using the old CrystalReports ActiveX control 'Crystl32.ocx'

I'm working on an application that is about 8 years old, and it uses version 8.0.0.4 of the Crystl32.ocx file for viewing reports. The issue is, when I go to view the report, it shows a parameter screen, that the user can CANCEL from. But, if you click CANCEL, the report window STILL opens, and shows a report with no data... (Or data ...