c++

How to step into C/C++ DLL from C# application while debugging

I have two project in my solution: C/C++ Win32 DLL and some C# application. What I have to do to be able to step into DLL while debugging? I switched on all debugging options in C++ project's settings and copied to C# application root next files: MyLib.dll, MyLib.pdb, vc90.pdb, vc90.idb, but it doesn't helped. What additional actions ...

Learning OpenGL through Java.

I'm interested in learning OpenGL and my favorite language at the time is Java. Can I reap its full (or most) benefits using things like JOGL or should I instead focus on getting stronger C++ skills? Btw, which is your Java OpenGL wrapper library of choice and why? ...

Why compiler is not giving error when signed value is assigned to unsigned integer? - C++

I know unsigned int can't hold negative values. But the following code compiles without any errors/warnings. unsigned int a = -10; When I print the variable a, I get a wrong value printed. If unsigned variables can't hold signed values, why do compilers allow them to compile without giving any error/warning? Any thoughts? Edit Comp...

Why does tm_sec range from 0-60 instead of 0-59 in time.h?

My time.h has the following definition of tm: struct tm { int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ ... } I just noticed that they document tm_sec as ranging between 0-60 inclusive. I've always assumed it ranged fro...

Should I worry about "Conditional jump or move depends on uninitialised value(s)"?

If you've used Memcheck (from Valgrind) you'll probably be familiar with this message... Conditional jump or move depends on uninitialized value(s) I've read about this and it simply occurs when you use an uninitialized value. MyClass s; s.DoStuff(); This will work because s is automatically initialized... So if this is the case...

Is memory allocated with new ever automatically freed?

I'm 99% certain the answer to this is a blinding no. Please validate my proposition that the following code will produce a memory leak. Data &getData() { Data *i = new Data(); return *i; } void exampleFunc() { Data d1 = getData(); Data d2; /* d1 is not deallocated because it is on the heap, and d2 is * because...

Why is Valgrind stating that my implementation of std::map<T, T> produces a memory leak?

Valgrind is outputting the following: ==14446== 2,976 (176 direct, 2,800 indirect) bytes in 2 blocks are definitely lost in loss record 23 of 33 ==14446== at 0x4C2506C: operator new(unsigned long) (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==14446== by 0x41C487: __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair...

Representation of wchar_t and char in WinDbg

Note: /* * Trivial code */ wchar_t *greeting = L"Hello World!"; char *greeting_ = "Hello World!"; WinDbg: 0:000> ?? greeting wchar_t * 0x00415810 "Hello World!" 0:000> ?? greeting_ char * 0x00415800 "Hello World!" 0:000> db 0x00415800 00415800 48 65 6c 6c 6f 20 57 6f-72 6c 64 21 00 00 00 00 Hello World!.... 00415810 48 00 65 00 6...

Obtaining current ModelView matrix

In OpenGL, how do I read the current x/y translation in the modelview matrix? I know that you have to load the current matrix into an array and read the floats from there, but I don't know precisely how to do it. ...

What happens to pixels after passing them into glTexImage2D()?

If for example I create an array of pixels, like so: int *getPixels() { int *pixels = new int[10]; pixels[0] = 1; pixels[1] = 0; pixels[1] = 1; // etc... } glTexImage2D(..., getPixels()); Does glTexImage2D use that reference or copy the pixels into it's own memory? If the answer is the former, then should I do th...

How to make this Matrix class easier to use in the debugger

I've written a C++ matrix template class. It's parameterized by its dimensions and by its datatype: template<int NRows, int NCols, typename T> struct Mat { typedef Mat<NRows, NCols, T> MyType; typedef T value_type; typedef const T *const_iterator; typedef T *iterator; enum { NumRows = NRows }; enum { NumCols = ...

Why does Valgrind not like my usage of glutCreateWindow?

I'm using the following code... 169: const char *title = Title.c_str(); 170: glutCreateWindow(title); ... Valgrind gives me the following ... ==28841== Conditional jump or move depends on uninitialised value(s) ==28841== at 0x6FF7A4C: (within /usr/lib64/libGLcore.so.180.44) ==28841== by 0x6FF81F7: (within /usr/lib64/libGLcore.s...

Are there equivalents to pread on different platforms?

I am writing a concurrent, persistent message queue in C++, which requires concurrent read access to a file without using memory mapped io. Short story is that several threads will need to read from different offsets of the file. Originally I had a file object that had typical read/write methods, and threads would acquire a mutex to cal...

Can you embed for loops (in each other) in C++

I am working on a merge sort function. I got the sort down - I am trying to get my merge part finished. Assume that I am learning C++, have cursory knowledge of pointers, and don't understand all the rules of std::vector::iterator's (or std::vector's, for that matter). Assume that num is the size of the original std::vector that have c...

Why does this compile in C but not C++ (sigaction)?

I get the following errors when trying to compile the below code using g++. When I compile it using gcc it works fine (other than a few warnings). Any help appreciated. g++ ush7.cpp ush7.cpp: In function ‘int signalsetup(sigaction*, sigset_t*, void (*)(int))’: ush7.cpp:93: error: expected unqualified-id before ‘catch’ ush7.cpp:95: err...

Is a compiletime constant index into a compiletime constant array itself compiletime constant?

I am trying to play fancy games which have the C++ compiler synthesize hash values of constant strings at compiletime. This would let me replace the string with a single identifier, with a massive savings in code size and complexity. For programming clarity and ease, it'd be awesome if I could examine and compute at compiletime with sim...

Wrapping up a C++ API in Java or .NET

Has anyone successfully "wrapped up" a C++ API in Java or .NET? I have an application that provides a C++ API for writing plug-ins. What I'd like to do is access that API from .NET or Java. Would I need to use COM, or are there simpler/better alternatives? ...

Is it good form to compare against changing values in a loop in C++?

No doubt some of you have seen my recent posting, all regarding the same program. I keep running into problems with it. To reiterate: still learning, not very advanced, don't understand pointers very well, not taking a class, don't understand OOP concepts at all, etc. This code just merges two sorted vectors, farray and sarray, into a si...

(C++ Query) Accessing the instantiated objects globally

This is a basic program to get two 5-digit numbers as string and use addition on the 2 numbers utilising operator overloading on '+' . #include <iostream> #include <limits> #include <cstdlib> #include <cstring> #include <sstream> using namespace std; class IntStr { int InputNum; public: //IntStr(); IntStr::IntStr(int ...

Memory leak in c++

I am running my c++ application on an intel Xscale device. The problem is, when I run my application offtarget (Ubuntu) with Valgrind, it does not show any memory leaks. But when I run it on the target system, it starts with 50K free memory, and reduces to 2K overnight. How to catch this kind of leakage, which is not being shown by Valg...