c++

How to determine a windows executables DLL dependencies programatically?

Anybody know how to determine what DLL's a binary depends on using programmatic methods? To be clear, I am not trying to determine the DLL dependencies of the running exec, but of any arbitrary exec (that may be missing a required DLL). I'm looking for a solution to implement in a C/C++ application. This is something that needs to be ...

Where exactly do function pointers point?

Given that all the primitive data types and objects have memory allocated, it is intuitively easy to imagine the pointers to these types. But where exactly do function pointers point to? Given that instructions are converted into machine code and reside in memory, should we consider they point to the memory location corresponding to the...

Why does the child process here not print anything?

Assume all the variables have been declared previously... because they have been. The child process does not print anything which makes me think it's not being executed. The parent process runs fine, albeit it doesn't get the shared memory. I apologize for the length of this code... // create 5 child process for(int k=0;k<5;k++){ ...

void* as unknown variable type

Hi, I'm currently working on a sprite engine in C++. I have an abstract class IEngine with a virtual function init_api. This takes in a void*. // Initialise the engines' API // api_params - void* to api parameters for initalisation // hWnd - window handle virtual bool init_api( void* api_params, HWND hWnd ) = 0; I then have a Dir...

How do you structure your comparison functions?

I frequently encounter situations, especially with sorting in C++, where I am comparing a series of fields in order to compare a larger structure. A simplified example: struct Car{ Manufacturer make; ModelName model; Year year; }; bool carLessThanComparator( const Car & car1, const Car & car2 ){ if( car1.make < car2.ma...

How to cope with high frequency data?

I have a C++ application which receives stock data and forward to another application via socket (acting as a server). Actually the WSASend function returns with error code 10055 after small seconds and I found that is the error message "No buffer space available. An operation on a socket could not be performed because the system lack...

How to print subscripts/superscripts on a CLI?

Hello there, I'm writing a piece of code which deals with math variables and indices, and I'd need to print subscripts and superscripts on a CLI, is there a (possibly cross-platform) way to do that? I'm working in vanilla C++. Note: I'd like this to be cross-platform, but since from the first answers this doesn't seem to be possible I'm...

Can I have a cross-platform cross-technology solution?

Hi , We have an old application which has a FORTRAN API to be called from other applications. After some time they built a ( C ) wrapper for the FORTRAN API.Then I'm now building a c++ wrapper , with a little data handling , for the C API. So I'm thinking what is the best way of building an API that can be called from any programming ...

Is friendship inherited in C++?

Suppose I have a Base class: class Base { friend SomeOtherClass; }; And there is another (different) class that inherits from Base: class AnotherClass : public Base {} Is friendship inherited as well? Thank you ...

How do I implement operator[] for dynamic array?

I have a need to implement dynamic array by myself to use it in simple memory manager. struct Block { int* offset; bool used; int size; Block(int* off=NULL, bool isUsed=false, int sz=0): offset(off), used(isUsed), size(sz) {} Block(const Block& b): offset(b.offset), used(b.used), size(b.size) {} }; class BlockList ...

Explain about linkages(external/internal) in c++?

Explain about linkages(external/internal) in c++? How does linkage differ for a function,constant,inline function,template function ,class and template class ...

Is it legal to use the increment operator in a C++ function call?

There's been some debate going on in this question about whether the following code is legal C++: std::list<item*>::iterator i = items.begin(); while (i != items.end()) { bool isActive = (*i)->update(); if (!isActive) { items.erase(i++); // *** Is this undefined behavior? *** } else { other_code_...

How do I call a object's member function as a unary_function for std algorithms?

I have a class that looks like this. class A { public: void doSomething(); } I have an array of these classes. I want to call doSomething() on each item in the array. What's the easiest way to do this using the algorithms header? ...

Forward declaring static C struct instances in C++

I'm writing a code generator, well, actually a data generator that will produce data structures of this form (obviously the actual data structures are much more elaborate): typedef struct Foo { int a; struct Foo* foo; } Foo; extern Foo f1; extern Foo f2; Foo f1 = {1, &f2}; Foo f2 = {2, &f1}; This is portable for all C and C++ co...

Weird vertexshader/pixelshader glitch

i've got a little problem with my water effect as you can see here, it doesn't show up the right way. another screen with a diffrent texture applied shows the error in the transform something more clearly my HLSL code: V2P vs(float4 inPos : POSITION, float2 inTex: TEXCOORD) { V2P Output = (V2P)0; float4x4 viewproj = mul (m...

Should I learn C before learning C++?

I visited a university CS department open day today and in the labs tour we sat down to play with a couple of final-year projects from undergraduate students. One was particularly good - a sort of FPS asteroids game. I decided to take a peek in the src directory to find it was done in C++ (most of the other projects were Java 3D apps). ...

Memory modifying in C++

im trying to learn to modify games in C++ not the game just the memory its using to get ammo whatnot so can someone point me to books ...

Most important things about C++ templates… lesson learned

What are most important things you know about templates: hidden features, common mistakes, best and most useful practices, tips...common mistakes/oversight/assumptions I am starting to implement most of my library/API using templates and would like to collect most common patterns, tips, etc., found in practice. Let me formalize the que...

Why do I get E_NOINTERFACE when creating an object that supports that interface?

Note: Using CoGetClassObject, to create multiple objects through a class object for which there is a CLSID in the system registry Single threaded apartment For instance: hresult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); IClassFactory *pIClassFactory; hresult = CoGetClassObject (clsid, CLSCTX_LOCAL_SERVER, NULL, IID_IClassF...

Creating a project, from Makefile to static/dynamic libraries in UNIX

Guys, would you describe a few things about c++ building blocks, on unix. I want to create an application that links against static libs and dynamic libs (.so). Question 1: How do I create static library using gcc/g++ ?How do I make my app link against it. Question 2: How to specify it in the makefile, linking against static and dy...