c++

Change Default Shell for Command Line Application Run From Visual Studio

When debugging or running command line applications from inside Visual Studio (2008 or 2010 in my case). It is possible to switch the default shell from cmd.exe to a something else? ...

Gain sole control of Audio Output, DirectSound

Hello, I am creating a basic signal generator and decided to use my audio card as the analogue output. I chose to use DirectSound because... it seemed like a good option. I have it up and running quite nicely, but I now realize that my code using secondary buffers and as such any other sounds on the computer get mixed in with my gener...

Passing class template as a function parameter

Hi, This question is a result of my lack of understanding of a situation, so please bear if it sounds overly stupid. I have a function in a class, like: Class A { void foo(int a, int b, ?) { ---- } } The third parameter I want to pass, is a typed parameter like classA<classB<double > > obj Is this possible? If not, can anybo...

Multithreading not taking advantage of multiple cores?

My computer is a dual core core2Duo. I have implemented multithreading in a slow area of my application but I still notice cpu usage never exceeds 50% and it still lags after many iterations. Is this normal? I was hopeing it would get my cpu up to 100% since im dividing it into 4 threads. Why could it still be capped at 50%? Thanks See...

Enumeration relying on integer boolean conversion

In my compiler project, I have an enumeration that goes like enum Result { No, Maybe, Yes }; I have put No explicitly at the first position, so that i can rely on the boolean evaluation to false. If my compiler is not sure about something, and has to wait for facts until runtime, its analysis functions will return Maybe. Used li...

Pushing a static array into a std::vector?

I'm trying to do the following: I have: std::vector<std::vector<GLdouble[2]>> ThreadPts(4); then I try to do: GLdouble tmp[2]; while(step--) { fx += dfx; fy += dfy; dfx += ddfx; dfy += ddfy; ddfx += dddfx; ddfy += dddfy; tmp[0] = fx; tmp[1] = fy; ThreadPts[currentvector].push_back(tmp); } ...

Writing a keyboard driver that accepts input from code

The ultimate goal of this project is to send low level input (so that it looks like it is coming from the keyboard) to my windows machine. I know C++, Python, and Java. Though I would love to do this in python, C++ will probably be the only option. I have been searching around the internet and have found something called a Keyboard Fil...

*** glibc detected *** free(): invalid pointer: 0x41e0ce94 ***

* glibc detected free(): invalid pointer: 0x41e0ce94 ** ,,, GCC is running well but ECLIPSE CDT using GCC is thwing this runtiime error ,why ? ...

Better way to copy several std::vectors into 1? (multithreading)

Here is what I'm doing: I'm taking in bezier points and running bezier interpolation then storing the result in a std::vector<std::vector<POINT>. The bezier calculation was slowing me down so this is what I did. I start with a std::vector<USERPOINT> which is a struct with a point and 2 other points for bezier handles. I divide these ...

stl list - complexity

Are all the inserts (anywhere) for the list constant? What about access? Front, back - constant time? and in the middle of the list - linear time? ...

Automatic Evaluation Strategy Selection in C++

Consider the following function template: template<typename T> void Foo(T) { // ... } Pass-by-value semantics make sense if T happens to be an integral type, or at least a type that's cheap to copy. Using pass-by-[const]-reference semantics, on the other hand, makes more sense if T happens to be an expensive type to copy. Let's ass...

Making worker threads?

Is there a way to make "worker threads" Basically I tried creating threads every time I needed them and this resulted in being slower than with 1 thread becase creating a new thread all the time is expensive. Would there be a way to create worker threads when the application first starts, then give them work when necessary? Thanks ...

On the fly font coloring in Tclsh via c++

Hello people! I am an amateur try to hack together a little project. It is a simple note storage and retrieval console app on Windows Vista (and XP - i'm hoping to run the whole thing off a USB Stick). I use Sqlite as the store and Tcl/SQL scripts to add notes (and tags!) and also retrieve them by tag. 3 tables and a "Toxi" schema. ...

Critique my concurrent queue

This is a concurrent queue I wrote which I plan on using in a thread pool I'm writing. I'm wondering if there are any performance improvements I could make. atomic_counter is pasted below if you're curious! #ifndef NS_CONCURRENT_QUEUE_HPP_INCLUDED #define NS_CONCURRENT_QUEUE_HPP_INCLUDED #include <ns/atomic_counter.hpp> #include <boost...

Cannot access INI files in "Program Files"

I wrote this C++ application that needs to check an INI file (“preference.ini”), and eventually modify it (e.g. if the user does not want to see the introduction form anymore). I created it in WinXP, and it works fine on the system where I compiled it (in many locations, including “Program Files”). Problem: In Win 7, it works fine if ...

Fastest way to calculate cubic bezier curves?

Right now I calculate it like this: double dx1 = a.RightHandle.x - a.UserPoint.x; double dy1 = a.RightHandle.y - a.UserPoint.y; double dx2 = b.LeftHandle.x - a.RightHandle.x; double dy2 = b.LeftHandle.y - a.RightHandle.y; double dx3 = b.UserPoint.x - b.LeftHandle.x; double dy3 = b.UserPoint.y - b.LeftHandle.y; ...

[C++/C] How to get a list of hosts connected to a mysql server

I am trying to get a list of hosts connected to a mysql server. How can i get this? What should i do after connecting to the mysql server. Code snippets will really help. Also whats the best api to use to connect to mysql using c++? ...

C++ RHEL53 Memory Fault Invalid read of size

I'm porting some old C++ project on Linux (RHEL 5.3) and, therefore need to obtain all the binaries on RHEL 5.3. The result should be in the end several libraries + the executable. I have some dependencies from several 3rd parties. My project libraries have dependencies as some of the 3rd party libraries. My library MyLib depends My3rd...

How to design a big class header file in c++?

I have a big C++ class, which includes 5 other classes inside, and some of them have other classes inside. The total length of a header (.h) file is very big and it is unreadable. This is what I'm trying to do: // Foo.h file #ifndef __INCLUDE_FOO_H #define __INCLUDE_FOO_H namespace foo { class Foo { public: #include "foo/Bar.h" void...

Unhandled Win32 exception

At runtime, when myApp.exe crashes i receive "Unhandled Win32 exception" but how would i know which exception was occurred? where did something went wrong? ...