c++

Moving an engineering application from standalone to internal to CAD

I have a large MFC C++ application that I would be very keen to port into AutoCAD and IntelliCAD. AutoDesk offer Object ARX for this purpose, which replaces the older and slower ADS technology. IntelliCAD, afaik only supports ADS. Has anyone out there done this, and if so which tools did you use and what pitfalls did you encounter? I...

How internally this works int const iVal = 5; (int&)iVal = 10;

I wanted to know how the following works @ compiler level. int const iVal = 5; (int&)iVal = 10; A bit of m/c or compiler level answer would be great full. Thanks in advance. ...

Nested struct in templated class with std::map::const_iterator?

The folowing code generates a syntax error at the line where the iterator is declared: template <typename T> class A { public: struct B { int x, y, z; }; void a() { std::map<int, B>::const_iterator itr; // error: ; expected before itr } std::vector<T> v; std::map<int, B> m; }; This o...

Is there a better way to design this message passing code?

class A was using below two functions to build and send messages 1 & 2 builder::prepareAndDeliverMsg1(msg1_arg1,msg1_arg2) { } builder::prepareAndDeliverMsg2(msg2_arg1,msg2_arg2) { } Now, a new class B is introduced, which would like to do what A was doing in two stages stage1->prepare stage2->deliver I was thinking to extend the ...

C++ Transformer scripting

Im looking to see if there are any pre-existing projects that do this. Generally, I need something that will load in a c++ file and parse it and then based on a set of rules in script, transform it, say to add headers, reformat, or remove coding quirks for example, turning const int parameters in functions to int parameters, etc Or perh...

How to implement usermode timer in C?

How we can implement our own timer function in Windows without using Library functions? Should we deal with assembly language instructions? ...

FastCGI cleanup code does not work under windows

Using apache on a windows server with mod_fastcgi, the C code looks like that: void main() { init(); while (FCGI_Accept() >= 0) work(); cleanup(); } When the service is taken down (i.e.: net stop apache2), the process terminates without getting to the cleanup code. What am I missing here? ...

C++ Memory Management for Texture Streaming in Videogames

Hi, this is a "hard" question. I've found nothing interesting over the web. I'm developing a Memory Management module for my company. We develop games for next-gen consoles (Xbox 360, PS3 and PC... we consider PC a console!). We'll need in future, for our next games, to handle texture streaming for large game worlds that cannot be load...

VC++ : How to prevent esc from closing a dialog box (not mfc)

How could I prevent esc from closing a dialog box? I searched for this topic, but all I found was for MFC (You can overwrite PreTranslateMessage function in MFC). but my program is written in Windows API, not MFC. I tried to catch all Keyboard messages in Dialog procedure, but none of them works. I also tried using subclassing in dialo...

what does "POR" mean in embedded development?

We have a third party device we are trying to integrated into our system and one of the things our code should do is start a hardware reset by asserting a reset pin. One of the documents mentions the pin being released before the end of POR. I bit of Google has given me this but I just wanted to confirm and understand if I am on the corr...

Whats the difference between the WIN32 and _WIN32 defines in c++

I know that WIN32 is obviously to denote win32 compilation but what is the need for _win32? ...

Websites like projecteuler.net

Sometimes I'm solving problems on projecteuler.net. Almost all problems are solvable with programs, but these tasks are more mathematical than programmatical. Maybe someone knows similar sites with: design tasks, architecture tasks, something like "find most elegant C++ solution"? ...

Could someone post a simple C or C++ TCP server and client example?

I need to quickly implement a very small C or C++ TCP server/client solution. This is simply to transfer literally an array of bytes from one computer to another - doesn't need to be scalable / over-complicated. The simpler the better. Quick and dirty if you can. I tried to use the code from this tutorial, but I couldn't get it to build...

Error in returning a pointer from a function that points to an array

Greetings Everyone, I'm in a bit of a fiddle in that I dont know why my code brings up the following error when compiling: 1>..\SA.cpp(81) : error C2664: 'CFE' : cannot convert parameter 1 from 'int' to 'int []' 1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast Esse...

Palette Animation in OpenGL

I am making an old-school 2d game, and I want to animate a specific color in my texture. Only ways I know are: opengl shaders. animating one color channel only. white texture under the color-animated texture. But I don't want to use shaders, I want to make this game as simple as possible, not many extra openGL functions etc.. And t...

Why can't I enter text in Winform hosted in ATL dialog?

I am working on embedding winform controls into an ATL dialog (see here for how I did so far). Now I have encountered a rather strange problem. For some reason, the text fields in my winforms display fine, but I am unable to change the text in them by typing on the keyboard. However, I can copy and paste text from elsewhere into the te...

C macro pitfalls

Duplicate: Good Programming Practices for Macro Definitions (#define) in C C (and by extension C++) macros are laden with pitfalls and practical problems when not implemented properly. Take, for example, the macro #define cube(x) x*x*x What is wrong with it? Where will it fail? When can unexpected results be returned? What is ...

What C++ library can I use to read pixels from DICOM images?

In C++ I want to read individual pixel values from DICOM images. ...

Why is std::for_each a non-modifying sequence operation?

I just read in the C++ standard that std::for_each is a non-modifying sequence operation, along with find, search and so on. Does that mean that the function applied to each element should not modify them? Why is that? What could possibly go wrong? Here is a sample code, where the sequence is modified. Can you see anything wrong with it...

How do I concatenate multiple C++ strings on one line?

C# has a syntax feature where you can concatenate many data types together on 1 line. string s = new String(); s += "Hello world, " + myInt + niceToSeeYouString; s += someChar1 + interestingDecimal + someChar2; What would be the equivalent in C++? As far as I can see, you'd have to do it all on separate lines as it doesn't support mul...