c++

Set a FourCC value in C++

I want to set a FourCC value in C++, i.e. an unsigned 4 byte integer. I suppose the obvious way is a #define, e.g. #define FOURCC(a,b,c,d) ( (uint32) (((d)<<24) | ((c)<<16) | ((b)<<8) | (a)) ) and then: uint32 id( FOURCC('b','l','a','h') ); What is the most elegant way you can think to do this? ...

Which Logging tools do you use for Windows?

I'm looking at adding logging to an application, and I'm considering using Kiwi syslogd and a freeware library (clSyslog) to send logging messages to the daemon. I briefly looked at log4c, and found compiling it with VC++ would take me more time than I had. What tools do you use and recommend for logging messages? ...

Windows Threading Wait Method

I'm creating a thread class to encapsulat the windows thread methods. I'm trying to create a method that makes the application wait for the thread to complete before it exits the application. If I use a while loop and boolean flag, it works but obviously it spikes my CPU use and its just not ideal. What ways would you use to wait for th...

C++ How to compile dll in a .exe

I am creating a c++ program, but I want to be able to offer just a .exe file to the user. However, I am using libraries (curl among others) which have some dll's. Is it possible to compile these dll's into the .exe file? I use Code::Blocks and mingw. ...

Why is the Visual C++ compiler calling the wrong overload here?

Why is the Visual C++ compiler calling the wrong overload here? I am have a subclass of ostream that I use to define a buffer for formatting. Sometimes I want to create a temporary and immediately insert a string into it with the usual << operator like this: M2Stream() << "the string"; Unfortunately, the program calls the operator<<(...

c++ optimization

I'm working on some existing c++ code that appears to be written poorly, and is very frequently called. I'm wondering if I should spend time changing it, or if the compiler is already optimizing the problem away. I'm using Visual Studio 2008. Here is an example: void someDrawingFunction(....) { GetContext().DrawSomething(...); Ge...

/MT and /MD builds crashing, but only when debugger isn't attached: how to debug?

I have a small single-threaded C++ application, compiled and linked using Visual Studio 2005, that uses boost (crc, program_options, and tokenizer), a smattering of STL, and assorted other system headers. (It's primary purpose is to read in a .csv and generate a custom binary .dat and a paired .h declaring structures that "explain" the ...

Search Outlook Contact using COM?

I want to add support for searching for local Outlook contacts to my ATL/WTL app. Does anyone know of the Outlook COM interface (Office 2003 or greater) allows you to search for contacts? I already have LDAP lookup support but users want to be able to search their private contacts as well. Any information would be welcome. ...

How to design my classes to leverege factory and be extensible?

My c++ SOA app has a concept of "session" that is used exchange data between services. In example its used for checking legality of some service A operations before executing session B which commits or rollback changes. Whatever. I have 2 types of session modes: normal and what-if. Going further, I have different session, session for le...

Is there any reason to use C instead of C++ for embedded development?

Question I have two compilers on my hardware C++ and C89 I'm thinking about using C++ with classes but without polymorphism (to avoid vtables). The main reasons I’d like to use C++ are: I prefer to use “inline” functions instead of macro definitions. I’d like to use namespaces as I prefixes clutter the code. I see C++ a bit type safe...

How to compress a directory with libbz2 in C++

I need to create a tarball of a directory and then compress it with bz2 in C++. Is there any decent tutorial on using libtar and libbz2? ...

How do I use a database in C++?

I've only really used phpMyAdmin and SQL calls from PHP to use a database before, and I want to use that same functionality in C++, but I'm not sure how to go about doing that. What is a good database system to use? Is there a good open source one available? What headers/functions do I need in order to connect to/use the database in C++?...

Strange integer value causing segmentation fault

I got a function find_nodes() with a loop inside: for (htmlNodePtr current_node=root_node ; current_node!=NULL ; current_node=current_node->next) { if (xmlHasProp(current_node,(xmlChar *)"href")) { if (xmlHasProp(current_node,(xmlChar *)attribute)) { if (strcmp(value, (char *)xmlGetProp(c...

Handling TCHARs in header files for libraries with different character sets.

I have a project that uses two third party libraries, both of which make use of TCHARs in their header files. Unfortunately one library is complied as multi-byte (call it library a), and the other is compiled as Unicode (call it library b). Now the way I understand it is that TCHAR is replaced by the precompiler with either wchar or cha...

hardware buffering using SDL, question about how it works

I'm deciding to do my first game, its going to be simple but I want to use c++ and I chose SDL for my learning. So my question is about how the "buffers" are handled when writing code. I'll post my related code at the bottom. Ok, so basically the way I understand it is that SDL takes care of which buffer is actually being drawn to the s...

Source Code Translator

I have to write program in C#, that converts from C++ source code to C# code. Is there any idea where to start? Do i have to use parser tree? Thanks! ...

In Qt how do I get a button press to set a spinbox to a certain value?

I'm trying to get to grips with Qt's signal and slots mechanism. I have an app with a QPushButton and a QSpinBox. When I click the button I want the spinbox to change to 20. What signal and slot do I need to set up? The code below shows the app, the connect function is the one I am having trouble with. As I understand it the setValue(in...

Wait until QWidget closes

I'm working on a project in C++ and QT, and I want to open a new QWidget window, have the user interact with it, etc, then have execution return to the method that opened the window. Example (MyClass inherits QWidiget): void doStuff(){ MyClass newWindow = new Myclass(); /* I don't want the code down here to ...

C/C++ Machine Learning Libraries for Clustering

What are some C/c++ Machine learning libraries that supports clustering of multi dimensional data? (for example K-Means) So far I have come across SGI MLC++ http://www.sgi.com/tech/mlc/ OpenCV MLL I am tempted to roll-my-own, but I am sure pre-existing ones are far better performance optimized with more eyes on code. ...

is it possible to use regex in c++?

Duplicate of: There is a function to use pattern matching (using regular expressions) in C++? I'm not sure where one would use it... are there any parser-type functions that take some regex as an argument or something? I just found out that my editor will highlight a line after / as "regex" for C/C++ syntax which I thought was weird... ...