c++

Books about how linking, compiling, etc and how it all fits together?

I'm having trouble understanding how compilers and linkers work and the files they create. More specifically, how do .cpp, .h, .lib, .dll, .o, .exe all work together? I am mostly interested in C++, but was also wondering about Java and C#. Any books/links would be appreciated! ...

How does delete[] know the size of an array?

Possible Duplicates: How does the standard new operator work in c++? How does delete[] “know” the size of the operand array? Dupe of http://stackoverflow.com/questions/197675/how-does-delete-know-the-size-of-the-operand-array I am curious how delete[] figures out the size of the allocated memory. When I do something like: in...

Are long-suffix and unsigned-suffix needed when declaring long literals in C++?

I have some ancient memories of writing C code like: long value = 0; in the bad old Win16 days and ending up with value being only half-initialized: i.e. the lower 16 bits were 0 and the upper 16 bits were whatever random bits were at that location in memory. As such, I became conditioned to write: long value = 0L; Is this still re...

xsd-based code generator to build xml?

I have a schema (xsd), and I want to create xml files that conform to it. I've found code generators that generate classes which can be loaded from an xml file (CodeSynthesis). But I'm looking to go the other direction. I want to generate code that will let me build an object which can easily be written out as an xml file. In C++. I...

Diagnosing an app that fails to halt

Our Windows app is often hanging in memory and I'm trying to use windbg to track down the problem. I'm very new to windbg and could use some advice (I have started to read Advanced Windows Debugging though). The app is a mix of C++ and COM objects written in VB. Occasionally when you exit, the app appears to go away but task manager sho...

Why do I need to close fds when reading and writing to the pipe?

Here is an example to illustrate what I mean: #include <stdio.h> #include <unistd.h> #include <sys/types.h> int main(void) { int fd[2], nbytes; pid_t childpid; char string[] = "Hello, world!\n"; char readbuffer[80]; pipe(fd); if((childpid = fork()) == -1) { ...

CArray and const template parameter

Is it possible to use const parameter to CArray I am currently using CArray like this but it won't compile: typedef CArray<const CString, const CString&> data_container; And I always get this compile error : error C2664: 'ATL::Checked::memcpy_s' : cannot convert parameter 1 from 'const CString *' to 'void *' ...

Setting another program's listview selected item

Hello I want to be able to select which item is selected in another program's list view(I don't have access to its code). Actually, it is an SysListView32, which I assume is the same. I already have the following code, which unfortunely despite compiling, seems to do nothing (although SendMessage() returns 1). process=OpenProcess(PROCE...

Automatically generate C++ Source and Header (and update vice versa on changes) files

Is there some tool (hopefully emacs) that can update and add the correct function definitions and other things to keep the source (.cpp) and the header (.h) files synchronized. For example if I start doing this file: aaa.h Class AAA { int b; public: void func(); }; something that will automatically create and add file: aaa.c...

Which is more similar to AS3, Java or C++?

I am ActionScript 3/Flex programmer, it is the first language I learned. I want to learn either Java or C++. Would one of these be easier to learn based on my current knowledge? ...

Stopping a service in c++ when do I use the ExitProcess() func

I'm stopping a service in my application wanted to know what is the usage of ExitProcess and if I should use it ...

C++ overloaded operator declaration and definition problems

I am having a hard time getting this to work file: myclass.hpp Class MyClass { public: template <class T> MyClass &operator<<(const T &val); }; file: myclass.cpp template <class T> MyClass &MyClass::operator<<(const T &val) { ... } I can compile this in to a object without a problem, But when other functions try to ca...

Issues with seeding a pseudo-random number generator more than once?

I've seen quite a few recommendations for not seeding pseudo-random number generators more than once per execution, but never accompanied by a thorough explanation. Of course, it is easy to see why the following (C/C++) example is not a good idea: int get_rand() { srand(time(NULL)); return rand(); } since calling get_rand several ...

Ever done a total rewrite of a large C++ application in C#?

I know Joel says to never do it, and I agree with this in most cases. I do think there are cases where it is justified. We have a large C++ application (around 250,000 total lines of code) that uses a MFC front end and a Windows service as the core components. We are thinking about moving the project to C#. The reasons we are thinking ...

C++ clean i18n library

I would like to have an easy to use way to write code like: #include <iostream> int main (){ std::cout << "hello, world!\n"; } but that supports i18n. Here is an example using gettext(): #include <libintl.h> #include <iostream> int main (){ std::cout << gettext("hello, world!\n"); } This can then be processed by xgettext to...

Sleep while holding a boost::interprocess::scoped_lock causes it to be never released

Hi, I'm doing IPC on Linux using boost::interprocess::shared_memory_object as per the reference (anonymous mutex example). There's a server process, which creates the shared_memory_object and writes to it, while holding an interprocess_mutex wrapped in a scoped_lock; and a client process which prints whatever the other one has written ...

wxWidget question

I use C++/MFC programming for developing some very basic applications. but I am looking for a C++ framework which can enhance my productivity as well as use the drag and drop feature(so that I can write programs like in .NET just drag controls and drop). and give me the C++ speed and native .exe + small .exe. can wxWidgets give me such ...

C++ slow, python fast? (in terms of development time)

I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast. Anyways, could anyone elaborate on this? What exactly makes development in ...

Under what circumstances is it advantageous to give an implementation of a pure virtual function?

In C++, it is legal to give an implementation of a pure virtual function: class C { public: virtual int f() = 0; }; int C::f() { return 0; } Why would you ever want to do this? Related question: The C++ faq lite contains an example: class Funct { public: virtual int doit(int x) = 0; virtual ~Funct() = 0; }; inline Funct::...

Inheritance issue when wrapping (inheriting) from a C++ library

The library I'm using has class G and class S which inherits G. I needed to add functionality to them, so I wrapped G and S, rather I inherited from them making Gnew and Snew respectively. So, my inheritance is: G --> Gnew | v S --> Snew But, I want to use Gnew in Snew and when I try to include the Gnew header...