c++

Good free profiler that supports MingW32 please?

I asked in another thread, how to profile my stuff, and people gave me lots of good replies, except that when I tried to use several of free profilers, including AMD Codeanalyst for example, they only support Microsoft PDB format, and MingW is unable to generate those. So, what profiler can help me profile a multi-threaded application w...

C - printf and scanf - How do I terminate input?

I am working on a simple application written in C. I am working in a Unix environment. My application is doing some simple I/O. I use printf to prompt the user for some input and then use scanf to get that input. The problem is, I don't know how to tell my application that I am ready to proceed after entering in a value. Typing 'enter'...

What C++ projects should I start?

Hey Guys, I'm a high school student, and I have a decent amount of programming experience (HTML, Javascript, PHP, Actionscript 3.0). I know C++, but unlike the other languages I know, I have never actually made any decent sized projects with it. I am puzzled at what kind of project I should start, as there are so many things you can do ...

Cannot Convert struct** to const POINT* for argument?

hi everyone im using winapi and i want to do a square in 3d im defining the points to unite them with a function and ive been trying 3 functions but i cant make them work i get the same error in the 3 of em >.< The Error says In member function `void Cube::Show(void)':| cannot convert `const Cube::Show()::POINT3D**' to `const POIN...

How does the pimpl idiom reduce dependencies?

Consider the following: PImpl.hpp class Impl; class PImpl { Impl* pimpl; PImpl() : pimpl(new Impl) { } ~PImpl() { delete pimpl; } void DoSomething(); }; PImpl.cpp #include "PImpl.hpp" #include "Impl.hpp" void PImpl::DoSomething() { pimpl->DoSomething(); } Impl.hpp class Impl { int data; public: void DoSo...

How to convert a float to a non standard encoding

I am writing a program that creates ICC color formats. These formats specify a data type called s15Fixed16Number which has a sign bit, 15 integer bits and 16 fractional bits. IEEE 754 32-bit floats have a sign bit, 8 exponent bits and 23 fractional bits. I need to get input from a text box, and convert them into a s15Fixed16Number. Some...

find with char* variable doesnt work

I'd like to know why I have a memory error with this: The problem appears on char* value = aMap.find(keync)->second If I put manualy char* value = "key0" it works!!! using std::map; map <char*, char*> aMap; void search(const char* key) { const int LEN = strlen(key); char* keync = new char[LEN]; for (int i= 0; i < LEN; i...

MultiCasting using UDP in C++

Hi, I want to develop one client server App using Multicasting using UDP in c++ Any code snippet or ideas... Thanks in Advance. ...

C++ writing PCM data on Windows vs OSX

As a warning, I'm not super savvy with DSP so this may be silly. I've got a callback method in an application that takes a float buffer and writes it to a queue, and then eventually to a file. The callback method looks like this: FMOD_RESULT F_CALLBACK dspCallback (FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, ...

g++ warning: comparison of unsigned expression < 0 is always false

To compile my C++ code I use the -W flag, which causes the warning: warning: comparison of unsigned expression < 0 is always false I believe this was considered as a bug and was fixed on version GCC 4.3, but I'm using GCC 4.1 Code that is obviously offending here: void FieldGroup::generateCreateMessage (const ApiEvent::GroupData ...

Macro return value

Can macro return an object? #define macro1 {obj1} Since macro is text substitution, could I use macro like macro1.function1()? Thanks. ...

How to detect whether there is anything left inside a boost archive

Is there a way to detect whether there is anything left inside a boost archive after I read from it? I tried this piece of code: const string s1("some text"); std::stringstream stream; boost::archive::polymorphic_text_oarchive oAr(stream); oAr << s1; boost::archive::polymorphic_text_iarchive iAr(stream); string s2; iAr >> s2; if (!str...

Removing duplicates in an array while preserving the order in C++

Possible Duplicate: How to make elements of vector unique? (remove non adjacent duplicates) Is there any standard algorithm which is provided as part of STL algorithms which can remove duplicates from an array while preserving the order. For example, if I have an array like int a[] = {2,1,3,1,4,2}; after the removal of duplica...

Cannot compile with memory dump for some files

Hi, I use this Debug.h file that I include as the last #include of the files where I want to debug for memory leaks. Then using _CrtDumpMemoryLeaks(); to dump it to my output.. This works fine for most files, but when I include it in some files I get the error below. It looks like it got to do with the boost::unorderer_map<> .. but I ca...

How does it work, Test *pObj = new Test(); as constructor does not return anything

Hi, I am trying to get better at c++. I have a Test class and below code in main(). Test *pObj = new Test(); If we debug by steping one by one instruction, First it goes to new function to allocate memory, then it calls constructor. Then it comes back to main() function. As we all know, constructor does not return anything. In that ca...

C++: copy array

Is it possible to do something like this in C++ (can't test it myself right now)? int myarray[10] = {111,222,333,444,555,666,777,888,999,1234}; void functioncc() { int temparray = myarray; for(int x=0; x<temparray.length; x++){ .... do something } } And maybe this (but i dont think it is): int array1[5] = {0,1,2,3,4,5,6,7,8,...

Compilation issues for Migration from VC6 to VC9

I am porting a legacy C++ system from VC6 to VC9. The application (<APP A>) statically links to an internal application <APP B> ( developed in house but by a separate team). A local copy of header files from <APP B> are included in CPP files and compiled in <APP A>. Currently we are not planning to migrate <APP B> to VC9. Though both ...

Operator Overloading with Chaining

I would like to overload << operator for chaining like below function1(param1, param2)<< obj2 << obj3 << string4 function1 would return an object. What I want to do is after string4, I need to call a function using param1, param2. My questions will be How do I know string4 is the last parameters in the expression and hence I need...

Visualize custom floating point class in debugger

I already did some fiddling in autoexp.dat to ease the inspection of custom string and other simple classes in the Visual Studio debugger (using vs2005). I'd really love to directly see the value (or approximation) of our custom floating point class. The internal representation is a quad-integer (int mantissa[4], 128bit on x86) that will...

event driven simulation with objects

hi everyone, i am writing an event driven simulation program. i have 3 subclasses that inherit 1 base class. i need to generate those three randomly and each subclass will go through different event path (sorry its a bit hard to describe what i meant), ill give an example: let say we have a car park simulation at a mall, we have the ba...