c++

Object Oriented Design help from C++ to C#

Hey I usually run into a situation where I will create a class that should only be instantiated by one or a few classes. In this case I would make its constructor private and make it a friend class to the objects that should be able to instantiate it. For example (in C++): class CFoo { // private ctor because only a select few class...

convert string to long long

Hi, I'm using VS 2008 to create a C++ DLL (not managed) project and I need convert a char* to a long long type. Is there an easy way to do it? Thanks in advance :) ...

Can you get a specific error condition when a C++ stream open fails?

Is there any way to get a specific error condition when a C++ stream open fails? That is, whether it failed because the file didn't exist, or permissions were wrong, or etc. Basically I'm looking for functionality equivalent to errno for fopen() in plain C. GCC seems to set errno properly, but that doesn't seem to be required by the C++...

Mutli-threaded application hanging on _dl_sysinfo_int80

I have a multi-threaded application that is hanging on a call to _dl_sysinfo_int80(). According to gdb, all threads are stuck in this call. The top of the stack trace looks like: #0 0x002727a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #1 0x004f23de in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0 #2 0x004ef00b in _L_...

Truncate a decimal value in c++

What's the easiest way to truncate a c++ float variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable? Thanks in advance! ...

Is C code still considered C++?

The comment to this answer got me wondering. I've always thought that C was a proper subset of C++, that is, any valid C code is valid C++ code by extension. Am I wrong about that? Is it possible to write a valid C program that is not valid C++ code? EDIT: This is really similar to, but not an exact duplicate of this question. ...

Why shared_ptr has an explicit constructor

I was wondering why shared_ptr doesn't have an implicit constructor. The fact it doesn't is alluded to here: http://stackoverflow.com/questions/142391/getting-a-boostsharedptr-for-this (I figured out the reason but thought it would be a fun question to post anyway.) #include <boost/shared_ptr.hpp> #include <iostream> using namespace b...

Simple Question about Visio 2007 (trying to create a simple UML diagram(C++) )?

I'm simply trying to create a UML diagram where I can show the header file declarations. I to be able to display things such as: Bitmap * getImage() Coordinate * getCoordinates(Object o) Stuff like that. Problem is, I can't figure out how to display pointers as return types(it only let's be choose objects from the UML diagram) or arg...

How do I create a sqllite3 in-memory database?

One of the appropriate uses for sqlite3 is "in-memory databases". This sounds like a really useful tool for my C++ applications. Does anyone have an example of how this is done in C or C++? I'm specifically looking for a canonical way to slurp several flat-files into an in-memory database, then do some joins. ...

Does anyone know of a C/C++ Unix QR-Code library?

I'm looking for a QR-Code library for C/C++, not Java or .Net please. Anyone knows of one? Note: There was a similar question a while back however but it didn't get answered properly. ...

Hibernate-like framework for C++

I am looking for database-caching framework for C++ providing the following: Generate object/table representations via some pseudo-language (macros/templates) Retrieve objects from DB by key when needed LRU caching Immediate and delayed update of DB on object update (via getter/setter methods) ...

Screen Rotation on Pocket PC

Hi, I am developing an application for pocket PC which should run in landscape mode. I wrote the function SetScreenOrientation(int angle), which rotates the screen. This function is called on application start and on application close. I want to change the screen orientation when I minimize/maximize orientation as well. To do this I ed...

How to estimate the thread context switching overhead?

I am trying to improve the performance of the threaded application with real-time deadlines. It is running on Windows Mobile and written in C / C++. I have a suspicion that high frequency of thread switching might be causing tangible overhead, but can neither prove it or disprove it. As everybody knows, lack of proof is not a proof of op...

Difference between using fork/execvp and system call

Hi What is the difference between using system() to execute a binary and using the combination of fork/execvp. Is there any security/portablility/performance difference. ...

Boost Spirit crash when used in DLLs

I am experiencing a crash while using the Boost.Spirit and Boost.Thread libraries in my application. This only happens if I have used the Spirit parser during the lifetime of the process from the main thread. The crash happens at exit and appears to be related to the clean-up of thread specific storage allocated by the Spirit parser....

Proper replacement for the missing 'finally' in C++

Since there is no finally in C++ you have to use the RAII design pattern instead, if you want your code to be exception safe. One way to do this is by using the destructor of a local class like this: void foo() { struct Finally { ~Finally() { /* cleanup code */ } } finalizer(); // ...code that might throw an exceptio...

Building console apps without CRT & default headers?

I'm trying to build a console application without using the CRT, or any other imports than kernel32.lib in any case. I get my code to compile, but can't wrap the linker around a few problems: unresolved external symbol @__security_check_cookie@4 unresolved external symbol "int __cdecl FreeLibrary(void *)" (?FreeLibrary@@YAHPAX@Z) unreso...

Can I set Visual Stdio 2005 to ignore assertions in a specific region of code while debugging....

Aaargh! OK, here's the scenario. I'm debugging my own app (C/C++) which is using some library developed by another team in the company. An assertion fails when my code generates some edge case. Its a pain because the assertion is not formulated correctly so the library function is working OK but I get all these interruptions where I jus...

CreateProcess from memory buffer

I can use CreateProcess to launch an EXE. I want to have the contents of an EXE in a memory buffer and do CreateProcess (or an equivalent) on it without having to write it to a file. Is there any way to do that? The backstory : we make games. We send a plain EXE to our distributors, which then wrap it using their favorite DRM and sell i...

P/SQL - setting null value

Hi, I have seen that there is a NVL function for P/SQL that substitutes a value when null is encountered. But what if I want to set a field to NULL, e.g. EXEC SQL UPDATE mytable SET myfield=NULL WHERE otherValue=1; When I run this with C++ on HPUX, 0L is used for null while on Linux the statement fails with "illegal value". Is there a...