c++

What can modify the frame pointer?

I have a very strange bug cropping up right now in a fairly massive C++ application at work (massive in terms of CPU and RAM usage as well as code length - in excess of 100,000 lines). This is running on a dual-core Sun Solaris 10 machine. The program subscribes to stock price feeds and displays them on "pages" configured by the user (a ...

Why is RegOpenKeyEx() returning error code 2 on Vista 64bit?

I was making the following call: result = RegOpenKeyEx(key, s, 0, KEY_READ, &key); (C++, Visual Studio 5, Vista 64bit). It is failing with error code 2 ("File not found") even though "regedit" shows that the key exists. This code has always worked on 32bit XP. Why is it "file not found" when it clearly is there? ...

Why do we even need the "delete[]" operator?

This is a question that's been nagging me for some time. I always thought that C++ should have been designed so that the "delete" operator (without brackets) works even with the "new[]" operator. In my opinion, writing this: int* p = new int; should be equivalent to allocating an array of 1 element: int* p = new int[1]; If this w...

auto c/c++

Has anyone ever seen the storage class auto explicitly in use in c/c++? If so, in what situation? ...

C++ : how to link against libA.so and not libA-X.Y.Z.so

I have a library A, that I develop. When I deploy it on a machine, the corresponding libA.so and libA-X.Y.Z.so are put in /usr/lib (X.Y.Z being the version number). Now I develop a library B, which uses A. When I link B, I use the flag -lA. Then "ldd libB.so" gives me : (...) libA-X.Y.Z.so => /usr/lib/libA-X.Y.Z.so (...) My problem...

Finding invocations of a certain function in a c++ file using python

I need to find all occurrences of a function call in a c++ file using python, and extract the arguments for each call. I'm playing with the pygccxml package, and extracting the arguments given a string with the function call is extremely easy: from pygccxml.declarations import call_invocation def test_is_call_invocation(call): if c...

Read 64 bit integer string from file

We have a file that has a 64 bit integer as a string in it. How do we scanf() or otherwise parse this numeric string into an unsigned 64 bit integer type in C++ ? We are aware of things like %lld etc., but a lot of ways to do this parse seem to break compiles under different compilers and stdlibs. The code should compile under gcc and ...

Is there an auto-update framework for C++/Win32/MFC (like Sparkle)?

I've decided to add auto-update functionality to one of my applications and was looking for any existing solutions that compare the current running version with the latest version that is then downloaded from the web. I know Sparkle on Mac OSX which is very nice and powerful, but was wondering whether there is something similar for Win3...

How do I print the elements of a C++ vector in GDB?

I want to examine the contents of a std::vector in GDB, how do I do it? Let's say it's a std::vector<int> for the sake of simplicity. ...

How to downsize std::vector?

Is there a way to resize a std::vector to lower capacity when I no longer need previously reserved space? ...

What are assertions? and why would you use them?

How are assertions done in c++? Example code is appreciated. ...

How do you inherit from a class in a different header file?

I am having dependency troubles. I have two classes: Graphic and Image. Each one has its own .cpp and .h files. I am declaring them as the following: Graphic.h: #include "Image.h" class Image; class Graphic { ... }; `Image.h`: #include "Graphic.h" class Graphic; class Image : public Gr...

How do I display a tooltip for a CMFCRibbonButton in the status bar?

I have a CMFCRibbonStatusBar in my mainframe to which I add a CMFCRibbonButtonsGroup which again has a CMFCRibbonButton. This button has the same ID as a menu entry. Creating the button is done as follows: CMFCRibbonButtonsGroup* pBGroup = new CMFCRibbonButtonsGroup(); CMFCToolBarImages images; images.SetImageSize(CSize(32, 16)); // N...

Why doesn't anyone upgrade their C compiler with advanced features?

struct elem { int i; char k; }; elem user; // compile error! struct elem user; // this is correct In the above piece of code we are getting an error for the first declaration. But this error doesn't occur with a C++ compiler. In C++ we don't need to use the keyword struct again and again. So why doesn't anyone update their C compile...

What parameter parser libraries are there for C++?

I'd like to pass parameters to my C++ program in the following manner: ./myprog --setting=value Are there any libraries which will help me to do this easily? See also http://stackoverflow.com/questions/189972/argument-parsing-helpers-for-c-unix/191821 ...

Weird #include problem

I have a problem with a simple included file. The file being included is in two MFC programs - one of which is a dll, and it also compiles itself into a non-mfc dll. Recently I was using the larger dll which wraps around the source of the smaller dll when I wanted access to some of the features of the original code that isn't exposed b...

Porting C++ code from Windows to the Mac

Howdy Ya'll, I'm a long time Windows developer, and it looks like I'm going to be involved in porting a Windows app to the Mac. We've decided to use Flex/Air for the gui for both sides, which looks really slick BTW. My Windows application has a C++ DLL that controls network adapters (wired and wireless). This is written using the stan...

How do I change the display name of a c++ windows service?

Where can I set the display name in the Service Control Manager of a c++ app? ...

Automake : what are the valid values for *_la_LDFLAGS in Makefile.am?

I am wondering what are the possible value for *_la_LDFLAGS in Makefile.am ? If I ask this question, it is because I would like the following : Actual shared library : libA.so (or with the version number I don't care) Symbolic links : libA-X.Y.Z.so, libA-X.so, libA.so soname : libA-X.so However here is what I ...

Crossplatform Bidirectional IPC

I have a project that I thought was going to be relatively easy, but is turning out to be more of a pain that I had hoped. First, most of the code I'm interacting with is legacy code that I don't have control over, so I can't do big paradigm changes. Here's a simplified explanation of what I need to do: Say I have a large number of si...