c++

Console application in C++ for smart devices (WinCE) ?

Hi, I am new in developing application for WinCE 5.0. I want to start from "Hello world" program or console application. But I couldn't find anything like that or any other sample applications to start from. I am using Visual Studio 2005. I created new project >> visual C++ >> Win32 smart device project >> console application >> finish....

Compute the absolute difference between unsigned integers using SSE

In C is there a branch-less technique to compute the absolute difference between two unsigned ints? For example given the variables a and b, I would like the value 2 for cases when a=3, b=5 or b=3, a=5. Ideally I would also like to be able to vectorize the computation using the SSE registers. ...

Tricky arithmetic or sleight of hand?

Vincent answered Fast Arc Cos algorithm by suggesting this function. float arccos(float x) { x = 1 - (x + 1); return pi * x / 2; } The question is, why x = 1 - (x + 1) and not x = -x? ...

How to intialize an integer pointer in C++ ?

Hi, I have a very simple question. I want to write the below line of code in 2 lines : IplImage *image = 0; like : IplImage *image; image = 0; I want to know what I have written is correct or else I want to know how to write the correct one (in two lines). Thanks ...

Linking ACE in QTCreator on Windows

I'm somewhat new to both QT and Windows development in general (I develop on Linux at work and rarely do GUI programming). Anyway, I downloaded ACE and built it with Visual Studio Express 2008 and have been able to use it in VS programs but I'm having trouble making it play nicely with QTCreator. My .pro file in QTCreator includes thes...

create makefile in c++

how create makefiles in c++ and why it is used? ...

Writing non-class types onto raw memory

Given a void pointer to a "blob" of raw memory, there are two ways of writing something onto it. The first way is to use placement new. This method has the advantage of calling the ctor automagically when we are dealing with class-types. However, when I deal with non-class types, would it be better to do a cast instead? I imagine it cou...

-L option not working for mingw gcc

I am trying to get mingw gcc to work. I need it to link with libopengl32.a. Said file exists in C:/mingw/lib. I used g++ as follows: g++ -L"C:/mingw/lib" main.o -o test.exe -llibopengl32.a It has no trouble finding the includes, it just complains that it can't find the library. It seems unable to find any other library as well. Al...

Java developer learning enterprise c++. Equivalent of JDBC abstraction?

I really enjoy the JDBC abstraction in Java. I don't care what database type I am connecting to, or what driver is being used. That's all set up in the DataSource object, and once it's done, we just use connections. It's such a consistent API in order to commit/rollback, perform transactions, and you only need to learn it once, and move ...

Using gcc/g++ instrument functions with MinGW?

Hello, i try to use the gcc instrument functions with g++ compiler of MinGW, but i always got linker issues. Is it possible to use the instrument functions with MinGW/MSYS? The linker failure output: $ g++ instrumentFunctions.cpp -o iftest -finstrument-functions >> iflog.txt C:/Users/HELLHO~1/AppData/Local/Temp/ccUwxrxt.o:instrumentFu...

iterating getters of a vector of pointers

Hi, I am trying to write an iterator class which returns a getter function return value when it is dereferenced. The code works fine, my only problem is that I would like to write the member_ptr_functor using only one template parameter and not 3, since I am supposed to be able to deduce the types of the argument and return value from th...

C++: Getting hex unexpectedly when printing array

Hi I am declaring an array using new int *a = NULL; a = new int[10]; a[0] = 23; a[1] = 43; a[2] = 45; a[3] = 76; a[4] = 34; a[5] = 85; a[6] = 34; a[7] = 97; a[8] = 45; a[9] = 22; PrintElements(a, 10); void PrintElements(int * array, int size){ for (int i=0; i<size; i++) { cout << endl << array[i]; } } Now when I pr...

Need help in finding name of specific thing I'm trying to do

I think it's possible to somehow hook with the windows environment (specifically explorer.exe) and trigger specific things, for example launching control panel and using it as if I had mouse (meaning I'm clicking the interface from the code). Basically what I'm trying to do is automate some redundant tasks I do often, just I don't know ...

C++ convert string to hexadecimal and vice versa

What is the best way to convert a string to hex and vice versa in C++? Example: A string like "Hello World" to hex format: 48656C6C6F20576F726C64 And from hex 48656C6C6F20576F726C64 to string: "Hello World" ...

Hash map, string compares, and std::map?

First off, I would like to make a few points I believe to be true. Please can these be verified? A hash map stores strings by converting them into an integer somehow. std::map is not a hash map, and if I'm using strings, I should consider using a hash map for memory issues? String compares are not good to rely on. If std::map is not...

How do I implement a callback in C++?

I want to implement a class in c++ that has a callback. So I think I need a method that has 2 arguments: the target object. (let's say *myObj) the pointer to a member function of the target object. (so i can do *myObj->memberFunc(); ) The conditions are: myObj can be from any class. the member function that is gonna be the callba...

Iterating over a map.

In this question I'm not asking how to do it but HOW IS IT DONE. I'm trying (as an excersise) implement simple map and although I do not have problems with implementing links and they behavior (how to find next place to insert new link etc.) I'm stuck with the problem how to implement iterating over a map. When you think about it and loo...

Win32 Device Context without Window

In my application i need to create HBITMAP objects to which I render and from where I copy the result. I use the function "CreateDIBSection" to create these bitmaps, however this function required a DC (Device Context) as first parameter. Currently I get this by calling GetDC(hWnd) on the main windows handle (hWnd). But I would like to...

Distributed computing framework in c/c++

I am looking for a way to make distributed computing over a network (lan). Is there any good framework or a library for this purpose in C/C++. ...

Setting TTL on outgoing ICMP packets?

Hi, I have been trying to set the TTL on ICMP packets using the boost::asio::ip::unicast::hops option (using Boost 1.43) and then reading it out with get_option. get_option gets 1 regardless what I use in set_option. And when inspecting the packets sent using wireshark, the TTL is 128. Am I missing something here? Should I use another ...