c++

Usage of D in the Field

I have tried to find some information on D. I do especially like this comparison with C++ to get an overview on what it is. Now I am asking myself: how often D is used in the field, and how much of a viable alternative is it to C++? ...

catch exceptions in Codegear CBuilder 2007 Forms

Hi, I have the problem to catch an EInOutError exception in CBuilder 2007 that is thrown inside an AsyncPro component. I have put a "try" statement around the Application->CreateForm() calls, but this covers only up to the constructor of the classes. From there the Forms run in their own thread and exceptions are not catched. Does anybo...

Whereto put "plugins" in linux

I am currently developing/hacking an image analyzing/transforming tool. The filters therein will be loaded at runtime using dlopen&co. My question is where do *nix tools usually put plugins (*.so files) when installed? bin/program lib/program/plugins/thisandthat.so maybe? Secondly how do I use it and where do I put it during develop...

Does c/c++ have a delay function?

Does c/c++ have a delay/wait/sleep function? ...

abstract an Interface `ISingleton` to be base class

Hi , I have 3 interface classes IVideo , IAudio , IGPIO and three other classes that will implement those interface: Video_impl , Audio_impl , GPIO_impl. Things is simple so far. But then ,I want all those object to be singleton. Here are the questions: Is it a good idea to abstract an Interface ISingleton , so that Video_impl , Audi...

Define a symbol in another namespace

Here is my problem: in a header I define a structure template type_to_string, which aims at defining a string corresponding to a given type argument: namespace foo { template <typename T> struct type_to_string { static const char * value; }; } template <typename T> const char * foo::type_to_string<T>::value = "...

How do I abort a MATLAB m-file function from C/C++?

I deployed a MATLAB project into a DLL, to be called from C++, and it works just fine. Happy days. But what happens when the user asks to cancel an operation? I tried creating a global variable named UserAborted. I initialize it to 0 before running the long function in MATLAB. I also wrote the following two functions: function AbortIf...

Problem with own Spinlock implementation

I made a very simple spinlock using the Interlocked functions in Windows and tested it on a dual-core CPU (two threads that increment a variable); The program seems to work OK (it gives the same result every time, which is not the case when no synchronization is used), but Intel Parallel Inspector says that there is a race condition at...

Data symbol exported in both DLLs despite dllimport

Hello, I have a problem concerning the export/import of a global variable in a DLL. I have a static library which contains a global variable such as : In the header : #ifdef _ENGINE_EXPORTS extern __declspec(dllexport) Globals data; #else extern __declspec(dllimport) Globals data; #endif In the source file : #ifdef _ENGINE_EXPORTS ...

Reparing a "disconnected" drive mapping

Sometimes a network drive that is already mapped to a drive letter because "disconnected". Using the normal Windows functions to access files / folders on that drive fail. As soon as the user manually clicks on that drive it the Windows Explorer dialog, it's magically repaired. Since my program is a batch program I'd like to start this ...

isDefined function?

In C++ is there any function that returns "true" when the variable is defined or false in vice versa. Something like this: bool isDefined(string varName) { if (a variable called "varName" is defined) return true; else return false; } ...

Does malloc/new return memory blocks from Cache or RAM?

Hi, I wanted to know whether malloc/new returns memory blocks from Cache or RAM. Thanks in advance. ...

C/C++ Libraries for reading from Universal Disk Format devices or files

Are there any good free C/C++ libraries that enable reading from common devices with filesystems such as UDF, and ISO9660 and extracting files/metadata etc.? So far all I've been able to find is GNUs libcdio which is promising, and some "Magic UDF" which has so many hits I'm disgusted, pushes other results in Google, and comes with a pr...

How to write a launching program in C++ or C# for Windows Vista

How do I write a program in C++ or C# that launches applications on Windows Vista? For example launching Dreamweaver CS 4 ("C:\Program Files\Adobe\Adobe Dreamweaver CS4\Dreamweaver.exe) and place it on top with the BringWindowToTop-function? ...

Storage of variables in memory

If I have a list of global variables like this... int a; char b; float c[10]; double d[3]; and I have an identical sequence of variables listed inside a class... class test_type { int a; char b; float c[10]; double d[3]; } is it guaranteed that the arrangement of all the variables in memory are identical. i.e. is 'b...

casting a pointer in Run Time [non-trivial Scnerio]

I have to fix a typical memory leak, Problem is like that : typedef std::map<unsigned long,Response> mapType; class Response { public: void *dataPtr; unsigned long tag; } class anyClass { public:: DataType x; } From client i am getting a map of Type mapType , Which has Response object as map->second , As Response object contain...

What's the C++ equivalent of UINT32_MAX?

In C99, I include stdint.h and that gives me UINT32_MAX as well as uint32_t. However, in C++ the UINT32_MAX gets defined out. I can define __STDC_LIMIT_MACROS before including stdint.h, but this doesn't work if someone is including my header after already including stdint.h themselves. So in C++, what's the standard way of finding out...

Normalizing from [0.5 - 1] to [0 - 1]

Hi all, I'm kind of stuck here, I guess it's a bit of a brain teaser. If I have numbers in the range between 0.5 to 1 how can I normalize it to be between 0 to 1? Thanks for any help, maybe I'm just a bit slow since I've been working for the past 24 hours straight O_O ...

Dllimport can't import an old Borland dll

I have a lot of legacy code which I currently compile using an antiquated install of Borland C++ 3.0. There's a rules engine in this code that I'd like to extract and use in a C# .NET application. The thing is, if I extract the rules engine into it's own DLL, I want to be able to call this DLL from both the existing legacy code which I...

Using dynamic multi-dimensional arrays in c++

I am making a C++ program that checks if given aray is a latin square. I need to use a dynamic multi-dimensional array that stores given latin square. But I cant pass the array to a function that does the checking... Currently I have such code for calling the function: int squaretest(int **p, int n, int sum) { //some code }; And...