c++

In Visual Studio 2010 why is the .NETFramework,Version=v4.0.AssemblyAttributes.cpp file created, and can I disable this?

I've recently upgraded to Visual Studio 2010. Now when I build projects I get a line that reads: 1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp I've learned that this is the result of the new build engine, msbuild.exe, but this file is actually auto-created and placed in my local temp directory (c:\Documents and Settings\me\Loc...

Can I bind an existing method to a LLVM Function* and use it from jitted code?

Hey guys, I'm toying around with the LLVM C++ API. I'd like to JIT compile code and run it. However, I need to call a C++ method from said jitted code. Normally, LLVM treats method calls as function calls with the object pointer passed as the first argument, so calling shouldn't be a problem. The real problem is to get that function in...

Type conditionals in C++ templates?

I have a method in C# as follows (which wraps a number across a range, say 0 to 360... if you pass 0-359 you get the same value, if you pass 360 you get 0, 361 gets 1, etc.): /// <summary> /// Wraps the value across the specified boundary range. /// /// If the value is in the range <paramref name="min"/> (inclusive) to ...

Getting input if the window is not active (Windows)

Hi, Short version: How can I receive input messages in Windows with C++/C when the window is not active? Background information: I'm currently working on an Input System that should not depend on any window, so it can e.g. be used in the console as well. My idea is to create an invisible window only receiving messages, which is poss...

C++ allocator<X>::deallocate(NULL,1) allowed?

Both free(NULL) and ::operator delete(NULL) are allowed. Does the allocator concept (e.g. std::allocator also allow deallocate(NULL,1), or is it required to put your own guard around it? ...

inline functions in c++

here is a small question about inline functions in c++. At what stage of the compilation in C++ are the inline functions actually inlined at the call? how does that basically work. lets say if the compiler has decided that a particualr function has to be inline after the programmer has requested with an inline keyword in front of the ...

exectuable dependancies on libraries

When sharing an executable do i really need to worry about libraries used to make that executable? seems like that should be taken into consideration when generating the exe not when you have to run it. Just curious. I am pretty sure I don't have to worry but wanted to ask this question to make sure. better to be safe than sorry. ...

Should I use the C or C++ implementation for returning a maximum size of a variable type?

From a standards standpoint, should I use the following from the C++ <limits> header? UCHAR_MAX which is the c implementation or std::numeric_limits<unsigned char>::max() which is the C++ implementation. The result is equivalent between the two versions but should I choose an implementation based on some standard or on readability and ...

How to detect client connection to a named pipe server using overlapped I/O?

I was studying the MSDN examples of using named pipes: Named pipe server using overlapped I/O Named pipe client The server easily detects when the client is disconnected and creates a instance of a named pipe. But I cannot figure out how the server knows that a client is connected to a pipe before any data from client is sent. Can s...

static initialization

Hi, the context I'm working on a project having some "modules". What I call a module here is a simple class, implementing a particular functionality and derivating from an abstract class GenericModule which force an interface. New modules are supposed to be added in the future. Several instances of a module can be loaded at the same ...

change value inside multimap

I have a multimap<key1,pair<key2, value2>> I want to change value2 in this multimap. typedef std::pair<int, int> comp_buf_pair; //pair<comp_t, dij> typedef std::pair<int, comp_buf_pair> node_buf_pair; typedef std::multimap<int, comp_buf_pair> buf_map; //key=PE, value = pair<comp_t, dij> typedef buf_map::iterator It_buf; buf_map b...

How to hide a function based on a template parameter

I'm using Visual Studio 2008. I have this class: template <bool T1> class Foo { public: void doSomething() {} Foo<T1>& operator=(int a) { doSomething(); return *this; } }; But I want that the method operator= be hidden (by simply doing: return *this) if the template parameter T1 is false. I need that for ...

Why is there no reallocation functionality in C++ allocators?

In C the standard memory handling functions are malloc(), realloc() and free(). However, C++ stdlib allocators only parallel two of them: there is no reallocation function. Of course, it would not be possible to do exactly the same as realloc(), because simply copying memory is not appropriate for non-aggregate types. But would there ...

Pointer arithmetic and dereferencing

In the following code, can anyone please explain to my what the line in bold is doing. struct southParkRec { int stan[4]; int *kyle[4]; int **kenny; string cartman; }; int main() { southParkRec cartoon; cartoon.stan[1] = 4; cartoon.kyle[0] = cartoon.stan + 1; cartoon.kenny = *(cartoon.kenny + 1) = ...

Analyzing .dmp files

Hello All, I am trying to solve a c++ exe run time error issue that happens only in production. I am new to C++ and windbg but I am pasting the enalysis here. I would greatly appreciate if some one can point me to as to how and under what condition this error occurs and more importantly how do I figure out which line of code is causing...

Using Iwebbrowser2 , I want the handle to the ie window created by navigate2

Hi Folks, In C++, I am creating an IE window (IE7) with CoCreateInstance, and using Navigate2 to navigate to a web page. I want to be able to get the handle to the IE window created by Navigate2. Notice in Navigate2, I give a window name as a parameter. Using get_HWND() is not working. I'm getting a handle to an IE window but not the o...

What is the most appropriate way to initialize a bi-dimensional array of objects?

I need a dinamically allocated bi-dimensional array of objects. I declared a static pointer to pointer to object as follows: server_session **server_session::Pglvcl_sess; There's a method to populate dinamically the array of array of object: int server_session::createSession() { int ret = -1; // looks for the next available posi...

How to get printf style compile-time warnings or errors

I would like to write a routine like printf, not functionally-wise, but rather I'd like the routine to have the same time compile check characteristics as printf. For example if i have: { int i; std::string s; printf("%d %d",i); printf("%d",s.c_str()); } The compiler complains like so: 1 cc1plus: warnings being treated a...

Using C++ from Python? (not boost)

I'm currently using boost-python to wrap a small C++ library and make it usable from Python. However, I'd like to stop using boost (mainly due to reasons relating to building/linking). So what other options are there? Is there something that's equally convenient to use? ...

Subtle syntax error in default parameter not caught by compiler

I started getting the error, "error C2059: syntax error : 'default argument'" for a line of code that declared a function with a string argument that was given a default parameter. This was obviously a bit frustrating, as the error message was not exactly enlightening (I know it's a 'default argument'!), and the exact declaration would ...