c++

help with async_read_until

I'm having trouble implmenting the 3rd parameter in the function documented here: http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/reference/async_read_until/overload4.html What I'd like to be able to do is use the callback on the 3rd parameter of async_read_until to detect when a complete chunk has arrived. My packets have the f...

Static linking vs dynamic linking

Are there any compelling performance reasons to choose static linking over dynamic linking or visa versa in certain situations? I've heard or read the following, but I don't know enough on the subject to vouch for their veracity. 1) The difference in performance between static linking and dynamic linking is usually negligible. 2) (1) i...

Boost numeric_cast<> with a default value instead of an exception?

Whenever boost's numeric_cast<> conversion fails, it throws an exception. Is there a similar template in boost that lets me specify a default value instead, or is catching the exception the only thing I can do in this case? I'm not too worried about the performance of all the extra exception handling, but I'd rather use a standard templ...

OpenGL: Rendering more than 8 lights, how?

How should I implement more than 8 lights in OpenGL? I would like to render unlimited amounts of lights efficiently. So, whats the preferred method for doing this? ...

Compiler error in declaring template friend class within a template class

Hello everybody. I have been trying to implement my own linked list class for didactic purposes. I specified the "List" class as friend inside the Iterator declaration, but it doesn't seem to compile. These are the interfaces of the 3 classes I've used: Node.h: #define null (Node<T> *) 0 template <class T> class Node { public: ...

compilation error about exceptions

Hi, I met some compilation error but do not know what the problem is. The code seems not use exception, but the error is about it. //in misc.h: char *basename(char *name); // line 94 // in misc.cc: char *basename(char *name) { // line 12 char *result = name; while(*name) { if(*name == '/') result = name + 1; name++;...

Why does my QGraphicsView not showing up in my MainWindow in Qt4?

This is probably something very obvious, but I have a new to Qt and can't figure it out. I have a simple MainWindow which has one button. When that button is clicked I want to create a QGraphicsScene, add a few lines and then show that in the Window. However when I run this code in a Window it does not show up. BUT, if I run this as a ...

malloc Error in specific makefile

I have a software, code of which I have modified and run make again. If I run the modified code in a black QtCreator project it runs well (nothing specific to Qt, just an example), but if I compile with software's original makefile, I get error on a line as: (*F)=(double**) malloc((size_arr)*sizeof(double*)); Not in compile time, but...

What is 'v' in vtable ?

What does v indicate in vtable or vptr ...

Casting between integers and pointers in C++

#include<iostream> using namespace std; int main() { int *p,*c; p=(int*)10; c=(int*)20; cout<<(int)p<<(int)c; } Somebody asked me "What is wrong with the above code?" and I couldn't figure it out. Someone please help me. ...

Resolving ambiguous calls in C++ with namespaces

I'm merging a static library (assimp) into an existing project (Spring RTS) where both the library and the project are under regular development. I'm trying to add the library in such a way that I can easily repeat the integration as new releases come out. Anyway, the issue is that Spring requires the library to perform all maths using ...

Passing a Delegate as Callback to a Native C++ API Call

Could someone point me whats wrong with this code please? I'm having a very hard experience in mixing C++ and MC++. I have read a lot of blogs and tutorial regarding this subject (passing delegates) but now that looks my code is ok (its compiling and runs well when in debug mode and step by step) it crashs. The main problem is that it n...

Linking error VC++

I download Neoncube downloader and tried to compile. After I resolved some linking issues, there's still three that I can't solve. 1>main.obj : error LNK2019: unresolved external symbol _UnEmbedBrowserObject referenced in function "long stdcall NoticeWindowProcedure(struct HWND *,unsigned int,unsigned int,long)" (?NoticeWindo...

how to use a resource file (txt - tab delimited) as a data source for win32 application

hi, i am working on a win32 app. i am currently using the text file which has tab delimited data as a source. i want to embed this as a resource so that i need not worry about shipping this file along with .exe file. can anyone tell me how to do it? ...

Windows network packet modification

I'm looking to write a small program which will intercept network packets (on the local machine) and modify them before they go out on the network. I need to be able to modify the headers as well, not just the data. I've already looked through several possibilities but am unsure which one is best to pursue. There are open source packet ...

Hooking DirectX EndScene from an injected DLL

I want to detour EndScene from an arbitrary DirectX 9 application to create a small overlay. As an example, you could take the frame counter overlay of FRAPS, which is shown in games when activated. I know the following methods to do this: Creating a new d3d9.dll, which is then copied to the games path. Since the current folder is sea...

Initialising C structures

Is there a better way to initialise C structures? I can use initialiser lists at the variable declaration point; however this isn't that useful if all arguments are not known at compile time, or if I'm not declaring a local/global instance, eg: Legacy C Code which declares the struct, and also has API's using it typedef struct { i...

c++ tool for visualising memory alignment?

Hi! Is there a tool, maybe a plugin for visual Studio or so, that visualizes for me the memoryalignment of my classes and structs? thx! ...

Design issues - observer,factory, composition and more

Hey, So i need to design something like that : I have a spreadsheet which can contain numerous sheets (maybe of different kinds). each sheet has let's say 1A-9Z cells. in each cell i can have one the above : String, Number, Formula - which means the cell gets an operation like +,-,/,* etc... and cells numbers, and in the cell i have ...

convert Class member callback from __stdcall to DWORD_PTR

Hi! I'm trying to use a class member as a callback but the compiler gives me the following error: Error 2 error C2440: 'type cast' : cannot convert from 'void (__stdcall CWaveIn::* )(HWAVEIN,UINT,DWORD_PTR,DWORD_PTR,DWORD_PTR)' to 'DWORD_PTR' Is it possible to use a member function as a callback this way? and how do I convert the std...