c++

Using a C/C++ data structure in a C# program

I have a super high-performance C/C++ data structure (see here!) that I'd like to access and use in my C# program. Imagine the C/C++ data structure has a public API (get, add, delete, etc). How can I call these methods lots of times within C# in a high-performance way? P.S. Before you criticize my use of the phrase "C/C++"... In my vie...

Substracting pointers: Where does this missing level of indirection come from?

Hi everybody, I'm having trouble understanding the behavior of the MS VC compiler on this one. This line compiles fine, but the result I get is not what I'd expect at all: this->Test((char *)&CS2 - (char *)&CS1 == sizeof(void *)); The CS1 and CS2 arguments are declared as follows: myFunction(tCS1* CS1, tCS2* CS2) {... tCS1 and tCS2...

c++ win32: how to set back color of a window?

I can set the back color when i am registering the class, e.g.: wincl.hbrBackground = CreateSolidBrush(RGB(202, 238, 255)); RegisterClassEx(&wincl); But how would i do it to any window i have created with the CreateWindow function? like a button on my main window, i have visual styles enabled, and i can notice the windows default gray...

Calling a C++ macro with fewer arguments

Hi, is it possible to call function-like-macros with less that all the parameters in linux? actually doing this only generates a warning in Visual Studio (warning 4003) and unassigned variables replaces with "". But compiling it using g++ generates an error in linux ("error: macro * requires ** arguments, but only ** given"). is there...

OpenGL flickering problem.

I'm trying to make a multi instance engine in C++ with a wrapper for C#. In made the engine in such way that there is a function like CreateEngine that takes as a parameter the handle to the window or control on which I want the engine to be initialized. In C# I made a custom control that initializes opengl for drawing and has a render e...

EvtArchiveExportedLog fails with ERROR_DIRECTORY

I need to export some events from Windows Event Log to XML on Windows Server 2008 R2. To achieve it I export these events to a file using EvtExportLog and then try to use EvtArchiveExportedLog to get localized descriptions for events. Here's the sample: EvtExportLog( 0, 0, query, logFileName, EvtExportLogChannelPath ); EvtArchiveExporte...

scanf / field lengths : using a variable / macro, C/C++

How can I use a variable to specify the field length when using scanf. For example: char word[20+1]; scanf(file, "%20s", word); Also, is it correct to use 20+1 (since it needs to add a \0 at the end?). Instead, I'd like to have something like: #define MAX_STRING_LENGTH 20 and then char word[MAX_STRING_LENGTH+1]; scanf(file, "%"MAX...

Program Memory Issue

Can I always assume that if... int main() { ... foo1(); foo2(); foo3(); ... return 0; } that foo1() will always precede foo2() and foo2() will always precede foo3() in program completion (referring to highest abstraction of completion)? In my actual program, whether foo2() and foo3() happen depend on whether f...

C++ Template function default value

Hi, is it possible to define default value for variables of a template functions in C++? something like below: template<class T> T sum(T a, T b, T c=????) { return a + b + c; } ...

map operations(find most occurence element)

here is code #include <iostream> #include <map> using namespace std; int main(){ map<int ,int>a; map<int,int>::iterator it; int b[]={2,4,3,5,2,6,6,3,6,4}; for (int i=0;i<(sizeof(b)/sizeof(b[0]));i++){ ++a[b[i]]; } // for (it=a.begin();it!=a.end();it++){ // cout<<(*it).first<<" =>"<<(*it).second<<"\...

force a new address space for a function (make static variables unstatic)

I got a function in a file that works for a single function call. But since it depends on alot of static declarations within this file (I didn't make this file, and its to big to modify). It wont work with multiple function calls. Is there some way to make each function call unaware of previous calls, or current calls? In effect force a...

How do I execute WinZip from Visual Studio without it's GUI opening?

int sysReturn = system("\"C:\\Program Files\\WinZip\\winzip32\" -a C:\\LOG\\test.zip C:\\LOG\\LOG_7-20-2010_17_8_48_834.csv"); Everything seems to work - as in it creates test.zip However, it opens the WinZip GUI (that shows how much has been compressed, etc while my program is running.) How can I skip that part where it doesn't ope...

Matrix Decomposition

I have a square n*n matrix S that has to be decomposed into a product of two matrices - A1 and A2, where A2 is transposed matrix to A1 (A2=A1^T) , so A1 * A2 = S. Are there any algorithms to do such operation effectively? C#/C++ solution would be nice. ...

C++ and CTime & System clock changing

Hello. I want to write simple application in C++ using ctime library. I'm getting the actual time and do some calculation in the loop. Very important for me is the fact that user can modify OS clock during calculations. Is there any way to get to know inside my app if the user has changed OS clock? Thnx for help in advance. PS. This ap...

Calculate QGraphicsTextItem font size based on scale

I have QGraphicsTextItem objects on a QGraphicsScene. The user can scale the QGraphicsTextItem objects by dragging the corners. (I am using a custom "transformation editor" to do this.) The user can also change the size of the QGraphicsTextItem by changing the font size from a property panel. What I would like to do is unify these so tha...

Automated test of client/server application

As the headline says, how would you test a client/server application, that is written in C/C++, that talks through a protocol over a network? Im a bit confused on how to do this. I have thought about making some mocking, but I have never tried mocking, so I dont know if this is the best way. How should I do this? I have written many unit...

How would i use a C++/CLI dll that wraps native code with multiple dependent libraries in C#?

I am wondering how I would go about correctly setting up a C++/CLI library that wraps native c++ code that has several dependencies. I have tried both statically and dynamically linking the native library to its dependent libraries with no luck. The Managed C++/CLI dll builds just fine and can be added as a reference to a C# project....

Tell Windows XP to Standby programmatically

How can I tell Windows XP to switch to standby mode programmatically with C/C++ native code? ...

Is it reasonable to write a server application in C# in my case?

I want it to work on windows servers. It will be a cloud type server - it'll consist of modules\parts running on different machines all over the world using http\tcp + upnp to connect to each other There are going to be controlling\monitoring\observing modules on each machine to provide stats on performance This net is going to be worki...

What HID device information is returned in LParam when a device is reported by the system?

I have been searching for information on this for about 30mins now and got nothing so far. Does anyone know what HID information is buried within LParam that's returned when the system (in this case windows) reports a system device change? (either removal or arrival) ...