c++

instantiate a new stl vector

Hello, I have a situation where i have a pointer to an stl vector so like vector<MyType*>* myvector; I have to set this pointer to NULL in the constructor and then lazy load when property is touched. how can i instantiate this to a new instance of a vector ? thanks -ashish ...

passing data from C++ to PHP

Hi, I need to pass a value from PHP to C++, this I think I can do with PHPs passthru(). Then I want C++ to do something to that value and return the result to PHP. This is the bit I can't work out, does anyone know how to pass data from C++ to PHP? I'd rather not use an intermediate file as I am thinking this will slow things down. Than...

HWND abc = 0x100; This does not work, and I understand why. How to do it then?

Hello I have a HWND variable that I want to point to an hardcoded value, just for testing purposes. I guess that HWND is a typedef of (int*) so that is causing some kind of indirection. What should the correct code be like? ...

Resources for cross-platform C/C++ development

What resources exist to aid in writing C/C++ code that works across multiple platforms and compilers? For example, I regularly find myself asking questions like: Which preprocessor macros are automatically defined in various compilers and environments? (e.g. __GCC__, WIN32, __WIN32__, __CYGWIN__) Which versions of compilers and standar...

Unit testing , approval testing and datafiles

(Leaving aside hair-splitting about if this is integration-testing or unit-testing.) I would rather first test at the large scale. If my app writes a VRML file that is the same as the reference one then the VRML exporter works, I don't then have to run unit tests on every single statement in the code. I would also like to use this do s...

C++ SQL database library comparison

Hi, I am starting development on a medium-scale C++ project that has to work with a Microsoft SQL Server database. I have done database work before using .NET technologies but I don't find using a .NET approach to be appropriate this time. I would like to get some feedback concerning the various free (as in GPL, LGPL, Boost) C/C++ SQL l...

FileSystemWatcher does not fire when using C++ std::ofstream

I'm trying to add a log monitor to an in-house test utility for a windows service I'm working on. The service is written in C++ (win32) and the utility is in .NET (C#) The log monitor works for many other C++ apps I've written, but not for my service. The only main difference I can see is that the other apps use the older ::WriteFile(...

What are my options for C++ DLL to call a C# DLL?

I have a C++ DLL that needs to call a function (pass a value, return a value) in a C# class library. Is my only option to give the C# DLL a COM interface and call it from C++ with IDispatch? Is this the best method? ...

Pointer-to-Exception Clean-Up

We all know that throwing pointers to exception is bad: try { ... throw new MyExceptionClass(); } catch (MyExceptionClass* e) { ... } What's your approach to cleaning the catch targets up in legacy code? I figure that I can fix the first part by making operator new private: class MyExceptionClass { public: ... private...

linux to windows C++ byte array

Hello, I have to replicate the following Java functionality in C++ to get data from Linux to Windows. Is Winsock2 the best way to go?. Also, any reference code to suggest? TIA, B import java.nio.ByteBuffer; public class MessageXdr { private ByteBuffer buffer; private int size; // taille max corps de message privat...

Can the signal system call be used with C++ static members of the class?

Is the following supported across *nix platforms? #include <cstdio> #include <sys/types.h> #include <signal.h> #include <unistd.h> class SignalProcessor { public: static void OnMySignal(int sig_num) { printf("Caught %d signal\n", sig_num); fflush(stdout); return; ...

create a control programmatically using MFC

Hello guyz, I just wonder how to do it. I write : CEdit m_wndEdit; and in the button event handler (dialog app), I write : m_wndEdit.Create(//with params); but I still don't see the control appear in the UI. help. I actually wrote this in the button handler : CWnd* pWnd = GetDlgItem(IDC_LIST1); CRect rect; pWnd->GetClientRect(&...

Trouble using ReadFile() to read a string from a text file

Hello everyone, How can I make the code below to read correct text. In my text file has Hello welcome to C++, however at the end of the text, it has a new line. With the code below, my readBuffer always contains extra characters. DWORD byteWritten; int fileSize = 0; //Use CreateFile to check if the file exists or not. HANDLE hFile =...

Issues in porting c/c++ code to VxWorks

Hi, I need to port a c/c++ codebase that already supports Linux/Mac, to VxWorks. I am pretty new to VxWorks. Could you let me know what are the possible issues that could arise? Thanks. ...

Refactoring build system to use Autotools

Over the past couple of days I have been reading into using autotools to build my project instead of the Makefiles I have pieced together over the past couple of months. Unfortunately I have not found an example that gave me enough insight towards how my project structure is currently. I have three libraries that are included in the app...

How to create a template function within a class? (C++)

I know it's possible to make a template function: template<typename T> void DoSomeThing(T x){} and it's possible to make a template class: template<typename T> class Object { public: int x; }; but is it possible to make a class not within a template, and then make a function in that class a template? Ie: //I have no idea if th...

Corba request timeout

I am working on a Corba client for some time. One problem that I run in is that I am not really able to define a timeout configuration. I am using a Mico C++ orb but it seems to be a global problem because I found noone who could describe if there is a Corba defined method to configure a request timeout. Does anyone know of such an int...

How can I pass data from a thread to the parent process?

I have a main process that uses a single thread library and I can only the library functions from the main process. I have a thread spawned by the parent process that puts info it receives from the network into a queue. I need to able to tell the main process that something is on the queue. Then it can access the queue and process the ...

View array in Visual Studio debugger?

Is it possible to view an array in the Visual Studio debugger? QuickWatch only shows the first element of the array. ...

Is there a way to initialize an array with non-constant variables? (C++)

I am trying to create a class as such: class CLASS { public: //stuff private: int x, y; char array[x][y]; }; Of course, it doesn't work until I change int x, y; to const static int x = 10, y = 10; Which is impractical, because I am trying to read the values of x and y from a file. So is there any way to initialize an a...