c++

boosts buffer into char* (no std::string)

So, it may be sounds as a realy newbies question... And proboly it is newbies :) I try to turn infomation from boost::asio::streambuf which I got, using read_until into char*. I've found realy many examples of turning it into std::string, but I'd mad, if use bufer -> std::string -> c_str in an application, needs a high perfomanse. (But ...

Compiler portable PDB(Program Database)?

Is there a standardized program database? I looked into the MAP file that the linker generates but it does not contain nearly enough information that I need. And I rather not use PDB because it is not officially documented and it is only for visual studio. ...

Does the caller need to Release the IShellBrowser* obtained via the undocumented WM_GETISHELLBROWSER (WM_USER+7) message?

Several have pointed out that there exists an undocumented message that retrieves the IShellBrowser interface pointer from the common dialog HWND for the file open & save dialogs. But there is conflicting information (or no information) on whether that pointer is AddRef'd, or if it is just the raw address returned, and no Release() shou...

Force derived class to call base function

If I derive a class from another one and overwrite a function, I can call the base function by calling Base::myFunction() inside the implementation of myFunc in the derived class. However- is there a way to define in my Base class that the base function is called in any case, also without having it called explicitly in the overwritten f...

Which Design Pattern / RTTI

I'm looking for the best way to dispatch objects to the correct "target" object. I have a base command class: Cmd, two sub-classes: BufferCmd and StateCmd. Command "GotoLine" is derived from BufferCmd and "ChangeCmd" is derived from StateCmd. BufferCmds are intended to go to a Buffer class and StateCmds are intended to go to a State o...

_popen: do not show the shell window (SW_HIDE)

When I execute the _popen command in c++ mfc it opens a shell window which I don't like, is it possible to make it hidden? for example when you try to execute commands with ShellExecute function it has the option to hide the shell window with SW_HIDE. ...

2D rendering with per-pixel lighting/normal map - directX

hiya. I'm looking for the simplest, easiest and fastest technique to render 2D textured quads with per-pixel normals. what i mean is a 3D world where the camera is fixed and all the texture quads are facing to the same direction (the camera), and between them there will be light points, and i want the textures to have per-pixel normal va...

C++ Eclipse Galileo getting it to display line numbers - how?

EDIT: jldupont's suggestion (see below) did the trick Window -> Preferences -> General -> Editors -> Text Editors -> Show line numbers I just installed Eclipse Galileo (first time) and am programing in C++ and couldn't get the editor to display the line numbers... When i Googled it I got these directions: Go to Window -> Pre...

C++ dereference vector pointer to access element

Hi! If i have in C++ a pointer to a vector: vector<int>* vecPtr; And i'd like to access an element of the vector, then i can do this by dereferncing the vector: int a = (*vecPtr)[i]; but will this dereferencing actually create a copy of my vector on the stack? let's say the vector stores 10000 ints, will by dereferencing the vecPt...

How do I find out if there is data available to be read from a socket in boost::asio?

I'm using the Boost ASIO library to write a TCP client program. The protocol starts with a banner line when you connect followed by '\r\n' I can send commands at any time much like smtp. However, the server can also send me data when I don't ask for it and it's terminated with a '\r\n' I have a line like to this to read and parse the ...

how can I map an int to a corresponding string in C/C++

I have 20 digits that I would like to associate with strings. Is there a faster way besides using a switch case I can do this with. Basically I need to convert an int to a correponding string and the numberes arent necessarily packed. Maybe there is something in Qt as well? for example 1 would be used to get "Request System Info" 2:...

[C++] Why aren't pointers initialized with NULL by default?

I guess this have been answered before, but I just couldn't find the answer here or on Google, but I think that it is because I couldn't type the right question... Can someone please explain why aren't pointers initialized to NULL? Example: void test(){ char *buf; if (!buf) // whatever } The program wouldn't ste...

what does std::endl represent exactly on each platform?

Thinking about UNIX, Windows and Mac and an output stream (both binary and text), What does does std::endl represent i.e. <CR><LF>, <LF> or <CR> or is it always the same no matter what platform/compiler? The reason I'm asking is that I'm writing a TCP client that talks a protocol that expects each command to end in <CR><LF>. So I'm w...

G++ not finding <iostream.h> in Ubuntu

I just installed Ubuntu and tried making the famed "Hello World" program to make sure that all the basics were working. For some reason though, g++ fails to compile my program with the error: "'cout' is not a member of 'std'". I've installed the build-essential package. Am I missing something else? #include <iostream.h> int main() {...

Remote C++ Debugging with RSE

I'm stuck after step 3 in trying to setup remote cross-debugging with Eclipse/RSE: Installed RSE 3.1 on Eclipse 3.5 Setup a SSH connection profile to my remote device built binaries using a cross-compiler Now I can't find the Eclipse option to transfer the binaries to my device and debug using gdb. Under Debug Configurations, I can't...

Is there a use for uninitialized pointers in C or C++?

In one of the comments in this question, it was brought out that initializing C++ pointers by default would break compatibility with C. That's fine, but why would something like this matter? I would think the only time it would actually matter is if I wanted an uninitialized pointer for some reason. But I can't think of a reason why I...

Can't compile std::list iterator with template

When I try to compile this I get this error: error: expected `;' before 'it' Why I can't declare this iterator? I don't understand... #include <list> template <typename Z> class LBFuncBase: public LBBaseBlock<Z> { void Something() { std::list<LBBaseBlock< Z >* >::iterator it; } } ...

way to implement IPC

what is the preferred way to implement IPC over windows ? i know of several like : named pipe, shared memory, semaphors ? , maybe COM (though i'm not sure how)... i wanted to know what's considered the most robust,fast,least error prone and easy to maintain/understand. ...

using openssl in c++

I used the openssl command line program to generate some keys and to sign some data. I'm now trying to use a c++ program that will verify the signing of these files with the public key. I know about the EVP_VerifyInit function and a few others, but I'm not sure how the EVP_PKEY object works and also, can I just read in the data files cre...

File-specific compilation options in Visual Studio 2008

If I had a project structured like this... a.cpp b.cpp c.cpp ...and I wanted to compile a.cpp and b.cpp with one set of compiler options, and c.cpp with another set, how would I do that? ...