c++

The procedure entry point _wsplitpath_s could not be locating in the dynamic link library msvcrt.dll

Recently upgrade a MFC++ Project which includes .NET assemblies from Visual Studio 2005 to 2008. Now whenever its installed it displays the following message: The procedure entry point _wsplitpath _s could not be locating in the dynamic link library msvcrt.dll I've install Microsoft Visual C++ 2008 SP1 Redistributable Package (x8...

Why does MIcroQuill Smartheap throw "mem_bad_pointer" errors after I embed perl?

I am embedding perl in a C++ application that uses Smartheap. Regardless of whether I compile the perl to use its own malloc or the system's I get a bunch of error mem___bad_pointer dialogs. It seems to work fine when I just click "ok" and ignore the errors, but obviously I need to actually solve the problem. Do I maybe need to compil...

Controlling object creation

I have a class whose object must be created on the heap. Is there any better way of doing this other than this: class A { public: static A* createInstance(); //Allocate using new and return static void deleteInstance(A*); //Free the memory using delete private: //Constructor and destructor are private so that the object can not b...

C++ member variable aliases?

I'm pretty sure this is possible, because I'm pretty sure I've seen it done. I think it is awesome, but I will gladly accept answers along the lines of "this is a terrible idea because ____". Say we have a basic struct. struct vertex { float x, y, z; }; Now, I want to implement aliases on these variables. vertex pos; vertex col;...

Building Boost for static linking (MinGW)

I'm building Boost (I'm using System and FileSystem) for MinGW using bjam: bjam --toolset=gcc stage And it builds fine, but I want to be able to statically link to it (I have to have a single file for the final product) so I tried: bjam --link=static --toolset=gcc stage But I get the same output. Any ideas? edit second question in...

How can I use TRACE macro in non mfc projects

I want to use the TRACE() macro to get output in the debug window in VS2005 in a non mfc c++ project. But I don't know which additional header or lib is needed. I want to know are there any ways of putting messages in the debug output window and how can i do that, thx a lot ...

When should you return a reference to a object from a class method

What is the best practice for returning references from class methods. Is it the case that basic types you want to return without a reference whereas class objects you want to return by reference. Any articles, best practices article that you recommend. ...

In Visual Studio can i plot my variable in breakpoint ?

In Visual Studio for my native C++ program I want to get a plot of some variables during debug. Mostly I use textual representation of the objects by editing autoexp.dat. But for some of the variables it is better to have a plot rather than having values in textual form. So far I have used a function plot(const void* address,const char*...

How to use resources in VC++?

I am using VC 9 and I want to support Russian language for my application. I even created Russian resource strings. But my system has Russian Language setting. If it is not there every character displays junk (its code page is 1251). I also made DLL from Russian resource file. If I run that DLL in application from installed location, it ...

Why can templates only be implemented in the header file?

The only portable way of using templates at the moment is to implement them in header files by using inline functions. What does this sentence mean? ...

Cancel a DeferWindowPos

I am doing a series of window resizing using the DeferWindowPos functionality. Suppose I already opened the DeferWindowPos handle, and called DeferWindowPos a few time, and now I want to cancel everything: not call EndDeferWindowPos. I tried CloseHandle( hDWP ), but it does not work (crash). If I simply return from my function, I ass...

How do I get past this variable initialization problem?

How do I get past this variable initialization problem? If I only could figure out how to only initialize them only once... * Main.cpp : main project file. /************************** Begin Header **************************/ #include "stdafx.h" //Required by Visual C ++ #include <string> //Required to use strings #include <iostr...

setsockopt TCP_NODELAY question on Windows Mobile

Hi all, I have a problem on Windows Mobile 6.0. I would like to create a TCP connection which does not use the Nagle algorithm, so it sends my data when I call "send" function, and does not buffer calls, having too small amount of data. I tried the following: BOOL b = TRUE; setsockopt(socketfd, IPPROTO_TCP, TCP_NODELAY, (char*)(&b)...

How do I use a third party dll in Visual Studio C++?

I understand that I need to use LoadLibrary(). But what other steps do I need to take in order to use a third party dll? I simply jumped into C++ and this is the only part that I do not get (as a Java programmer). I am just looking into how I can use a Qt Library and tesseract-ocr, yet the process makes no sense to me and is so difficult...

What is the best way to implement a heartbeat in C++ to check for socket connectivity?

Hey gang. I have just written a client and server in C++ using sys/socket. I need to handle a situation where the client is still active but the server is down. One suggested way to do this is to use a heartbeat to periodically assert connectivity. And if there is none to try to reconnect every X seconds for Y period of time, and the...

Most efficient replacement for IsBadReadPtr?

I have some Visual C++ code that receives a pointer to a buffer with data that needs to be processed by my code and the length of that buffer. Due to a bug outside my control, sometimes this pointer comes into my code uninitialized or otherwise unsuitable for reading (i.e. it causes a crash when I try to access the data in the buffer.) ...

Best way to compare elements in a vector and return a object

I have a use case wherein numbers are monotonically increasing in an vector of integers vec[0] = 2 vec[1] = 5 vec[2] = 8 vec[3] = 10 .. If I am passed number 6, I want to return vec[1], since it lies between vec[1] and vec[2], similarly if passes 9 would have to return vec[2]. My experience with STL is limited , so wanted to check can...

How do I write binary data for 7z archive format?

I've been pouring over the format description and source code for the 7z archive format, but I'm still having trouble writing a valid container. I assume I can create an empty container... anyway here's my start: std::ofstream ofs(archivename.c_str(), std::ios::binary|std::ios::trunc); Byte signature[6] = {'7', 'z', 0xBC, 0xAF, 0x27,...

How to use T4 code generation templates with VS C++ projects?

T4 template files are automatically recognizable by the IDE under C# projects, but I have no clue on how they can be integrated into C++ projects (other than using make files). Any ideas? ...

Semantics of char a[]

I recently embarrassed myself while explaining to a colleague why char a[100]; scanf("%s", &a); // notice a & in front of 'a' is very bad and that the slightly better way to do it is: char a[100]; scanf("%s", a); // notice no & in front of 'a' Ok. For everybody getting ready to tell me why scanf should not be used anyway for securi...