c++

vc++ .h file compile error in g++

Hi, I have a .h,.dll and a .lib file given to me by a vendor all compiled in visual studio. I try to link the library in g++ and I get an error in the .h file that I dont understand. The error is: error: qualifiers can only be specified for objects and functions at several lines that have no qualifiers. It occurs randomly at if statem...

What is IconnectionPoint and EventHandling

Trying to understand What is IConnectionPoint and how this is connected to IConnectionPointContainer,IEnumConnectionPoints,IEnumConnections and EventHandling. Read the artcicles from MSDN and CodeProject which is explaining a about other methods like: QueryInterface() and otherthings. I am unable to figure out how all these things(ICo...

what should I do to get the new process using a new command prompt window ?

I got two console applications that the first one runs the second one: 1_first console application: #include <Tchar.h> #include <windows.h> #include <iostream> using namespace std; void main(){ PROCESS_INFORMATION obj1; memset(&obj1,0,sizeof(PROCESS_INFORMATION)); STARTUPINFOW obj2; memset(&obj2,0,sizeof(STARTUPINFOW)); obj2.cb...

Memory cleanup issue converting QString to char* for use with a 3rd party library, how to solve?

I am using a 3rd party library with Qt that requires char* strings. I am using the following code to convert my QString to a char* char* toCharArray(const QString &string) { QByteArray bytes = string.toLocal8Bit(); char* data = new char[bytes.count() + 1]; strcpy(data, bytes.data()); return data; } // later on... 3rdPa...

How should a size-limited stl-like container be implemented?

While refactoring, I wanted to change an array where entries are added to an std::vector, but for compatibility (persistency, downgrading,...), it still needs to have an upper limit. What is the best way (elegant, stl-like, limited extra code) to have an stl-like container which is limited in size, so you know that inserting an entry fai...

Class name macro

Possible Duplicate: CLASS macro in C++ Hello, are there any ways to get name of class with macro like _FUNCTION_ for function name? The only ideas I have is inheriting some base class with pure virtual toString and define the names by hands eash time. Thanks. ...

Is it viable to do video streaming via pipe in windows?

Is the pipe efficient enough to continuously pass video streams to other applications? If yes,can you provide a sample code in c/c++? ...

std::map and _CrtIsValidHeapPointer error

i try to use the std::map with class DEMO { public: DEMO(); virtual ~DEMO(); DEMO &operator =(const DEMO &d); DEMO(const DEMO& d); BYTE* Arr() const; private: BYTE *m_array; }; DEMO &DEMO::operator =(const DEMO &d) { memcpy(m_array, d.Arr(), 1); return *this; } DEMO::DEM...

Getting the type of passed argument in variadic function

Is there any trick to get the type of the passed in arguments without explicitly stating the type in a string as one of the argument? To add on the post just now, basically what I want to do is if is type A call functionA else if is type B call functionB. Could variadic template solve that? Thanks. ...

analysis of core file

hi I'm using Linux redhat 3, can someone explain how is that possible that i am able to analyze with gdb , a core dump generated in Linux redhat 5 ? not that i complaint :) but i need to be sure this will always work... ? EDIT: the shared libraries are the same version, so no worries about that, they are placed in a shaerd storage ...

Why is type_info::name() unspecified?

I'm fully aware that the return value of std::type_info::name() is implementation-defined. From the C++ standard (ISO/IEC 14882:2003 §18.5.1.7): Returns: an implementation-defined NTBS. My question is: why? Wouldn't this member function be much more useful if the standard dictated what the return value should be? ...

valid fragment of this code in c++

what is valid form of this code in visual c++? this does not work i took it from microsoft using namespace System; int main() { Console::WriteLine(__CLR_VER); } ...

Using boost to create a lambda function which always throws

Is it possible to create an inline lambda using boost which always throws an exception? (this question follows on from "Using boost to create a lambda function which always returns true"). Suppose I have a function which takes some form of predicate: void Foo( boost::function<bool(int,int,int)> predicate ); If I want to call it with...

Print ascii table 0-127

Hello, got a question regarding printing out the 128 first characters from the ascii table. I haven't gotten so far yet, because I already stumbled to a problem. The following code prints the correct value starting from 32-127. From 0 to 31 however it prints out some scrap values. I assume it is correct as well since I quick checkup on t...

Accessibility of variables.

HI, i have small doubt related to the accessibility of variables. int i; //default the linkage is external const int i; //default linkage is internal extern int i; //explicitly assigning linkage as external class a { int l; //Default linkage is external void f() { int k; //default linkage is e...

memory leak detecting in C++ with/without Visual Leak Detector

Hi All I want to detect memory leaks of my C++ program in Windows. I read the documentation also on MSDN about mermoy leak detection and I also started using Visual Leak Detector. I have a doubt about the reporting of the leaks. I am expecting a file name with a line number, but I am always reported the text below. It has all the compo...

Display ieee 32bit representation of float ... strange behaviour on pointer output

Hello everyone, I have a bit of trouble with the following code: void main() { float value = 100; char * vP; vP = (char *) &value; printf ("%02x ", *(vP+3)); printf ("%02x ", *(vP+2)); printf ("%02x ", *(vP+1)); printf ("%02x ", *(vP+0)); } The output I get is: 42 ffffffc8 00 00 instead of: 42 c8 00 00 (as required for an IEE...

What is .cfi and .LFE in assembly code produced by GCC from c++ program?

I have the following c++ code int factorial(int n){ if(n==0){ return 1; } return n*factorial(n-1); } int main(void){ factorial(5); return 0; } When I create an assembly file using g++ -S factorial.cpp I get the following: .file "tail_call_opt.cpp" .text .globl _Z9factoriali .type _Z9fact...

How to make tr1::array allocate aligned memory?

You can allocate a std::vector which allocates aligned heap memory by defining your own allocator. You can allocate a c-style array on the stack using declspec align. But can you declare a tr1::array which guarantees that the element at index zero will be aligned? ...

Difference between double comparisons in gtest (C++) and nunit (C#)

I have done porting of a c++ project with gtest tests to a c# project having an nunit test. Now I encounter problems with floating point precision. in the nunit test I have being not ok (red) Assert.AreEqual(0.7, 7 * 0.1); in the gtest test I have: ASSERT_DOUBLE_EQ(0.7, 7 * 0.1); which is ok (green) The question now is WHY??? ...