c++

C++ definition of dllimport static data member

Hi, I do have a class which looks like below: //.h file class __declspec(dllimport) MyClass { public: //stuff private: static int myInt; }; // .cpp file int MyClass::myInt = 0; I get the following compile error: error C2491: 'MyClass::myInt' : definition of dllimport static data member not allowed what should I d...

Global keyboard hook with C++

I've already saw many tutorials and articles about hooking, yet I don't quite understand it. Mainly because every single example uses different solution. I know I will have to implement something that will keep the hook alive. Usually it's some kind of while cycle. Q1: If this loop was in some class with callbacks, will it prevent the t...

string to binary

I convert a character to binary using std::bitset<CHAR_BIT> binary('c'); but this doesn't work for a string, std::string str = "MyString"; std::bitset<SIZE_OF_STRING_IN_BITS> binary(str); //Error Exception what should be the alternative? ...

converting angle to radian

Hi, I got angle in degree as -415 degrees, i have converted it into radian as float degreeValue = -415 float radianValue = degreeValue * pi / 180.0; here i got as -0.7(round off) how to convert again into degree to get same value of angle in degrees. ...

How to cope with “... failed to start. Veryfy that you have sufficent privileges..."?

:( i can't install my msi file because of that. does anyone know why is that? ...

forward declaration in c++

I want to forward declare: namespace boost { namespace property_tree { template<typename Key, typename Data, typename KeyCompare = std::less<Key> > class basic_ptree; typedef basic_ptree< std::string, std::string > ptree; } } but my g++ cribs about redefinition due to default template argument. How can ...

How is marshalling performed when C++ code is called from C++/CLI?

According to this question it's possible to seamlessly combine managed and unmanaged code using C++/CLI. I don't quite get it - shouldn't there be marshalling between managed and unmanaged anyway? For example, I have InnerLibrary that is compiled as a native C++ .dll with a header published and C++/CLI OuterLibrary that calls code from ...

Compile-time 'String' Manipulation with Variadic Templates

Hey all, I'm currently trying to write a compile-time string encryption (using the words 'string' and 'encryption' quite loosely) lib. What I have so far is as follows: // Cacluate narrow string length at compile-time template <char... ArgsT> struct CountArgs { template <char... ArgsInnerT> struct Counter; template <char Cur, char.....

double dealloc problem while cleaning up a C++ STL list of pointers

Hi all, Problem: I try to deallocate memory pointed by pointer items of an STL list. This should work fine but in my case, there can be duplicate pointers in the list and I get a double dealloc exception even though I test whether the pointer is NULL or not (see source code below). How can I solve this problem ? Environment: Debian...

Need a tool to get C++ Inheritance Heirarchy of existing project?

I am trying to understand WebKit (2 Million lines of C++ code). I want a tool which takes a class name as input and tell me the names of all classes which inherit from it. For example, if I pass in "RenderObject" it should return RenderInline, RenderBox. I am using Fedora 13 and for debugging purpose I am using QtCreator IDE. ...

gdb cannot watch variables declared inside for-loop

I am using gcc 4.1.2 20080704 (Red Hat 4.1.2-48) GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5_5.1) and I cannot watch variables declared inside for-loop. I tried to recreate this behavior on a smaller example but it worked fine. Seems like this problem shows up only inside complex class member functions. Please, advise. EDIT: o...

Overloading overloaded operator=?

What can I do when I need different job done, depending on the rval and lval type? Defining several overloads pop out with error 'operator = is ambiguous'. Any ideas, or tips (links to tutorials), are much appreciated, since I've just today found out about operator overloading. Thanks in advance! EDIT: Yes, I'd use C++0x since I have...

Basic DirectX11 problem, code crashes as soon as I begin drawing anything to the screen. Also help with Netbeans configuration.

So, I started programming in DirectX11 today, I've had a lot experience with coding, but not specifically DirectX, so I went and look at some tutorials. All was going swell, I could initialize a window, set a background color, but then as soon as I tried to define a shader and draw an object, it just crashes on load. This code is extreme...

Macros as default param for function argument

Hello, I'm writing logger file. I'd prefer to use macros _FUNCTION_ there. I don't like the way like: Logger.write("Message", __FUNCTION__); Maybe, it's possible to make something like: void write(const string &message, string functionName = __FUNCTION__) { // ... } If not, are there any ways to do that stuff not by hands (I mea...

measuring code coverage of an unit test using aqtime

Hi, I want to measure the code coverage of an unit test with aqtime. The application to test uses a lot of boost functionality. Now these boost methods appear in the test report. With these methods in the report, it is nearly impossible to interpret it since I did not test boost but the classes using boost. Is there a fast way to exclu...

Member templates

Can any one explain this "A using-declaration in a derived class cannot refer to a specialization of a template conversion function in a base class." it is from ISO C++ Standard ..14.5.2 ,point 7 ...

Difference between GetModuleHandle and including header

Hi, maybe stupid question, but i dont know answer. What is difference between using GetModuleHandle or LoadLibrary to load dll(and then to use function of that dll) and to include directly desired header. For example, with using GetModuleHandle: typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); // Call GetNativeSystemInfo if supported or Ge...

Is there a way to prohibit the use of a class by value in c style variable arguments list?

Accidential use of classes inside of c style typeless variable arguments list is a common error source. Example: class MyString { public: char *pChars; int Length; MyString(char *pChars) { this->pChars = pChars; Length = strlen(pChars); } }; int main() { MyString s1("Bla1"), s2("Bla2"); ...

Union query and C++

I use MySQL database and C++ programming language. In my database there are 20 tables. I produce different messages from these tables. All tables include dateTime columns and I want to sort produced messages. I did it by using union. But query is so long. Do you think it has another way or my way is correct. Thans a lot. ...

Problem to Decode H264 video over RTP with ffmpeg (libavcodec)

I set profile_idc, level_idc, extradata et extradata_size of AvCodecContext with the profile-level-id et sprop-parameter-set of the SDP. I separate the decoding of Coded Slice, SPS, PPS and NAL_IDR_SLICE packet : Init: uint8_t start_sequence[]= {0, 0, 1}; int size= recv(id_de_la_socket,(char*) rtpReceive,65535,0); Coded Slice : cha...