c++

Concepts and Design of PluginController

I ran across a cute plugin controller on this site TinyURL.com/ns42lv and would like to find out where I can learn more about the concept/design of a plug in controller. I use Windows as my OS and do most of my programming in C++. ...

Unmanaged C++ Get the current process id? (Console Application)

How can I get the current process id from an unmanaged C++ console application? I see that GetWindowThreadProcessId Works when you have an HWND, but what can I do for a console application? ...

C++: access const member vars through class or an instance?

In C++, is there any reason to not access static member variables through a class instance? I know Java frowns on this and was wondering if it matters in C++. Example: class Foo { static const int ZERO = 0; static const int ONE = 1; ... }; void bar(const Foo& inst) { // is this ok? int val1 = inst.ZERO; // or should I p...

Socket remains open after program has closed (C++)

Hey folks, I'm currently writing a small server application, and my problem is, that when I close my app (or better, press the terminate button in eclipse), the socket sometimes stays open, so when I execute my app the next time, bind() will fail with "Address already in use". How can I properly close my sockets when the program exits? I...

switch case programming practice

enum SQLErrorCode{ OK = 0, PARTIAL_OK = 1, SOMEWHAT_OK = 2, NOT_OK = 3, }; Code 1: int error = getErrorCode(); if((error == SQLErrorCode.PARTIAL_OK) || (error == SQLErrorCode.SOMEWHAT_OK) || (error == SQLErrorCode.NOT_OK) || (error < 0)) callFunction1(); else callFunction2(); Code 2: switch(erro...

Windows Pre-Caching SQLite problem

SQLite is a great little database, but I am having an issue with it on Windows. It can take up to 50 seconds to perform a query on a 100MB database the first time the application is launched. Subsequent loads take 10% of that time. After some discussions on the SQLite mailing list, I am told "The bug is in Windows. It aggressively pre-...

What is a .h.gch file?

I have a question. I recently had a class project where I had to make a program with G++. I used a makefile and for some reason it occasionally left a .h.gch file behind. Sometimes, this didn't affect the compilation, but every so often it would result in the compiler issuing an error for an issue which had been fixed or which did not...

How can I persist an environment variable to the visual studio build helper?

I've got an NMake project in Visual Studio 2008 that has the Build command set to a custom tool that performs a long build task. Build = "@call MyTool -config $(ConfigurationName)" I want a way to to pass a special flag ("-quickbuild") to my tool to tell it to do a quick subset of the overall build. Build = "@call MyTool -config $(Con...

Why doesn’t WPF support C++.NET - the way WinForms does?

As a C++ stickler, this has really been bugging me. I've always liked the idea of the "language-independant framework" that Microsoft came up with roughly a decade ago. Why have they dropped the ball on this idea? Does anyone know the reasoning behind it? ...

New to SDL OpenGL on Linux, whats wrong with this?

I have written some code to experiment with opengl programming on Ubuntu, its been a little while but I used to have a reasonable understanding of C. Since c++ i'm told is the language of choice for games programming I am trying to develop with it. This is my first real attempt at opengl with sdl and I have gotten to this far, it compil...

Unable to return struct from C++ back to C#

I have a C# program that is calling into a native C++ dll. The C# has a the following struct: [StructLayout(LayoutKind.Sequential)] public struct Phenomenon { [MarshalAs(UnmanagedType.U1)] public char Type; [MarshalAs(UnmanagedType.R8)] public double Jd; [MarshalAs(UnmanagedType.R8)] public double Loc_jd; [MarshalAs(Un...

push_back(this) pushes wrong pointer onto vector

I have a vector of UnderlyingClass pointers stored in another object, and inside a method in UnderlyingClass I want to add the "this" pointer to the end of that vector. When I look at the contents of the vector immediately after the push_back call, the wrong pointer is in there. What could be going wrong? cout << "this: " << this << e...

What is the most efficient way to display decoded video frames in Qt?

What is the fastest way to display images to a Qt widget? I have decoded the video using libavformat and libavcodec, so I already have raw RGB or YCbCr 4:2:0 frames. I am currently using a QGraphicsView with a QGraphicsScene object containing a QGraphicsPixmapItem. I am currently getting the frame data into a QPixmap by using the QIma...

import .reg files using win32 or other libraries

My question is a bit related to this one but it's not what I was aiming for: http://stackoverflow.com/questions/35070/programmatically-merge-reg-file-into-win32-registry What I want to do is to create a program that can import a .reg file using win32 or some other library. I tried looking around but failed at that part. Something like...

C++ header policy on large projects (redux)

I've read everything I could find on this topic, including a couple of very helpful discussions on this site, the NASA coding guidelines and Google C++ guidelines. I even bought the "physical C++ design" book recommended on here (sorry, forgot the name) and got some useful ideas from that. Most sources seem to agree - header files shou...

loop condition evaluation

Hello everyone, Just a quick question. I have a loop that looks like this: for (int i = 0; i < dim * dim; i++) Is the condition in a for loop re-evaluated on every loop? If so, would it be more efficient to do something like this?: int dimSquare = dim * dim; for (int i = 0; i < dimSquare; i++) Thanks -Faken ...

C++ Memory Efficient Solution for Ax=b Linear Algebra System

I am using Numeric Library Bindings for Boost UBlas to solve a simple linear system. The following works fine, except it is limited to handling matrices A(m x m) for relatively small 'm'. In practice I have a much larger matrix with dimension m= 10^6 (up to 10^7). Is there existing C++ approach for solving Ax=b that uses memory efficien...

How to release memory from std::deque?

I'm using a std::deque to store a fairly large number of objects. If I remove a bunch of those objects, it appears to me that its memory usage does not decrease, in a similar fashion to std::vector. Is there a way to reduce it? I know that in a vector you have to use the 'swap trick', which I assume would work here too, but I'd rather a...

How to use "make" to use 64 bit libs because of ELFCLASS64 error

How can I use configure and make tools to specify to use 64 bit libraries ? I thought it was automatic, but I get wrong ELF Class I'm trying to compile xdebug for ubuntu 64 for use with lampp (xampp for linux) ./lampp start Failed loading /opt/lampp/lib/php/extensions/xdebug.so: /opt/lampp/lib/php/extensions/xdebug.so: wrong ELF c...

Windows 7 Development Platform

As some of you may have noticed, a few hours ago Microsoft released Windows 7 RTM to those of us with a Technet or MSDN subscription. I unfortunately didn't have the opportunity time-wise to test the new OS. I'm asking of anyone who used it with Visual Studio 2008 during RC what was your experience? Did you feel the RC offered a stable ...