c++

Using C++ COM interface in C# for both client and server

Hi all, I need to make a piece of C# code interact through COM with all kinds of implementations. To make it easeier for users of that integration, I included the interacted interfaces in IDL (as part of a relevant existing DLL, but without coclass or implementation), then got that into my C# code by running Tlbimp to create the types ...

Set OLE Request Timeout from C++

I am instantiating a local COM server using CoCreateInstance. Sometimes the application providing the server takes a long time to start. When this happens, Windows pops a dialog box like this: Server Busy The action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the ...

Waitpid equivalent with timeout?

Imagine I have a process that starts several child processes. The parent needs to know when a child exits. I can use waitpid, but then if/when the parent needs to exit I have no way of telling the thread that is blocked in waitpid to exit gracefully and join it. It's nice to have things clean up themselves, but it may not be that big of...

How to get memory usage under Windows in C++

I am trying to find out how much memory my application is consuming from within the program itself. The memory usage I am looking for is the number reported in the "Mem Usage" column on the Processes tab of Windows Task Manager. ...

demote boost::function to a plain function pointer

want to pass boost::bind to a method expecting a plain function pointer (same signature). typedef void TriggerProc_type(Variable*,void*); void InitVariable(TriggerProc_type *proc); boost::function<void (Variable*, void*)> triggerProc ... InitVariable(triggerProc); error C2664: 'InitVariable' : cannot convert parameter 1 from 'boost::f...

How to create an alias for a build target with a relative path in Scons?

Background I'm trying out Scons by setting up a basic C++ sample project that has two sub-projects: Prj1 is an EXE that depends on Prj2 Prj2 is a DLL that exports some functions You can see the directory structure and the contents of my SConstruct and SConscript files here Problem The problem I'm running into is that in order to b...

Commenting out comments

I've noticed, using visual studio 2003, that I can "comment out" my comments to make them no longer be comments. This one needs an example: If I have: /* int commented_out = 0; */ I can comment out the /* and */ with // and code within the /* and */ is no longer "commented out" (the text changes to non-comment color and the compiler ...

C++ Opening a file and inputting data to a class object

Simple question, hopefully an easy way and just want to verify I'm doing it the correct / efficient way. I have a class T object, which is typically put into a vector that is created in my main() function. It can be any kind of data, string, int, float.. etc. I'm reading from a file... which is inputted from the user and passed onto t...

C++ compiler optimization of passed arguments

I'm using a logging module that can have reporting enabled/disabled at runtime. Calls generally go something like: WARN( "Danger Will Robinson! There are " + boost::lexical_cast<string>(minutes) + " minutes of oxygen left!" ); I'm using an inline function for WARN, but I'm curious as to how much optimization is going on...

Calculating the maximum size of derived classes.

We have a My_list class that has a list of pointers to Abstract_things. To optimize on memory usage, all derived Things use one memory pool that is established with the "new and delete" stereotype. In order to size the pool properly during the initization of the application, the builder figures out which Thing is the biggest and sizes ...

How to call c++ binary from Perl or PHP (CGI-BIN using Apache on Linux ) ?

I have a website cgi-bin program that is written in c++. Unfortunately the website provider for my friend's site only allows Perl or PHP cgi-bin scripts. Is there an easy way to simply have a very small Perl or PHP wrapper that just calls the c++ compiled binary? Would the c++ program still be able to read from stdin for POST comman...

ld: duplicate symbol

I'm working on a school project and I'm getting some weird errors from Xcode. I'm using TextMate's Command+R function to compile the project. Compilation seems to work okay but linking fails with an error message I don't understand. ld output: ld: duplicate symbol text_field(std::basic_istream >&)in /path/final/build/final.build/Re...

C++ odd compile error: error: changes meaning of "Object" from class "Object"

I don't even know where to go with this. Google wasn't very helpful. As with my previous question. I'm using TextMate's Command+R to compile the project. game.h:16:error: declaration of ‘Player* HalfSet::Player() const’ players.h:11:error: changes meaning of ‘Player’ from ‘class Player’ game.h:21:error: ‘Player’ is not a t...

Using Chromium as a MFC CWnd

Hey all. I am looking to using Google Chromium for my MFC app as an HTML renderer. I found this test bed application and I am wondering if anyone knows how or of a resource that I can make sense of it so that I could extract the Webkit/Webview stuff into my application. Thanks. ~/webkit/tools/test_shell ~/webkit/tools/test/reference...

How to pass large struct back and forth between between C++ and Lua

I am looking at embedding Lua in a C++ application I am developing. My intention is to use Lua to script what ordered operation(s) to perform for some given input, ie. receive a new work item in c++ program, pass details to Lua backend, Lua calls back into c++ to carry out necessary work, returns finished results. The primary data stru...

C++ and memory question

I've read some C++ books explaining how it's important to delete new-allocated memory. I have learnt some strategies like encapsuling the created object inside another object where its destructor will be called, etc, etc. However, if we have a singleton used during all the life of a program.. is it "really" important to delete it? As ...

Easy way to convert a struct tm (expressed in UTC) to time_t type

How do I do the above? There is mktime function but that treats the input as expressed in local time but how do i perform the conversion if my input tm variable happens to be in UTC. ...

What Web services/Interface to use?

We are designing a system with C/C++ back end server and C# .NET front end. We would like to provide a web interface similar to C# .NET front end. Can you please suggest the best way to do it? e.g. Whether to embed the web server in back end server itself? How to have maximum common code between in .NET and web interface to minimize the ...

SendMessage API in 64 bit

According to MSDN The return value specifies the result of the message processing; it depends on the message sent. I know it is defined as typedef LONG_PTR LRESULT; Meaning it will be 8 bytes on 64bit machine but (!) .... Does anyone know if it is safe to assume that only the lower 4 bytes are used and store it as an IN...

function returns and dynamic memory question

I have a dll that must be useable from C etc, so I cant use string objects etc as a normal would, but I'm not sure on how to do this safely.. const char *GetString() { std::stringstream ss; ss << "The random number is: " << rand(); return ss.str().c_str(); } could the c string be destroyed when ss falls off the stack? I'm ...