c++

Can doxygen handle DocXML style comments from C++ code

I'm trying out the Atomineer addin to document my c++ code, and I want to use the DocXML format that VS uses in csharp code. I can create the comments, but running doxygen over the project directory always results in warnings like this: Warning: documented function `bool CBaseItem::ValidateInterval' was not declared or defined. All fun...

Why do un-named C++ objects destruct before the scope block ends?

The following code prints one,two,three. Is that desired and true for all C++ compilers? class Foo { const char* m_name; public: Foo(const char* name) : m_name(name) {} ~Foo() { printf("%s\n", m_name); } }; void main() { Foo foo("three"); Foo("one"); // un-named object printf("two\n"); } ...

Eclipse CDT Custom Compiler Error Parsing Plugin

I'm using an uncommon C compiler with Eclipse CDT. I have a make file setup which is nice, but I'd like IDE integration with the error / warning output of my compiler. Does anybody know what steps I can take to write a plugin for parsing / supporting my compilers output? I think it should be easy but there is a barrier of entry of fig...

C++ pthreads - using code I used in C gives me a conversion error

I am running the same exact code that I ran in plain C: pthread_create(&threads[i], &attr, SomeMethod, ptrChar); And I get the errors: error: invalid conversion from 'void*(*)(char'*)' to 'void*(*)(void*)' error: initializing argument 3 of 'int pthread_create(__pthread_t**, __pthread_attr_t* conts*, void*(*)(void*), voi...

How do I determine the number of places following a decimal in a floating point value?

In C++ you can use std::numeric_limits<FloatingPointType>::digits10 to find out exactly how many places of precision you can get before the decimal place. How do I find out how many decimal places I can get following it, if I know the number will always be fixed-point between 0 and 1 inclusive? Edit: The reason I ask is that I have an...

Strategy for handling linker errors?

Given a C++/gpl toolchain, what's a good method or tool to puzzle out linker errors? ...

Comparison of performance between Scala etc. and C/C++/Fortran?

Hi all, I wonder if there is any reliable comparison of performance between "modern" multithreading-specialized languages like e.g. scala and "classic" "lower-level" languages like C, C++, Fortran using parallel libs like MPI, Posix or even Open-MP. Any links and suggestions welcome. ...

How to get the currently focused menu item ID?

I want to display info when my mouse cursor is on an item in my menu by using SendMessage() to my statusbar. How do i get the current menu item ID ? I suppose they use same ID's as my Visual Studio shows in the menu editor. I found these on msdn but none of them seems to serve my needs: WM_COMMAND WM_CONTEXTMENU WM_ENTERMENULOOP WM_EXI...

For a given number N i have to find all the prime numbers it's consisting of

Need a suggestion for an algorithm. For a given number N i have to find all the prime numbers it's consisting of, like this: N = 49 49 = 7 ^ 2 N = 168 168 = (2 ^ 3) * (3 ^ 1) * (7 ^ 1) If you want to help me even more you can write the algo in c++. Thanks. ...

Why does function calls to templatized base classes not work?

Consider the following example: template <typename T> class A { public: void f() { cout << "A::f()\n"; } }; template<> class A<int> { }; template<typename T> class B: public A<T> { public: void g() { cout << "B::g()\n"; A<T>::f(); } }; int main() { B<int>...

Sending data between two ethernet interfaces on the same box

I would like to send data between two ethernet interfaces that are connected with a crossover cable in Linux. The two ethernet interfaces are on the same box. I defined the ethernet interfaces to have different static ip addresses (1.2.3.4 and 5.6.7.8) and have been using sockets to send bytes from one IP address to the other. I want ...

Problem with sprintf function, last parameters are wrong when written

So I use sprintf sprintf(buffer, "%f|%f|%f|%f|%f|%f|%d|%f|%d", x, y, z, u, v, w, nID, dDistance, nConfig); But when I print the buffer I get the 2 last parameters wrong, they are lets suppose to be 35.0000 and 0 and in the string they are 0.00000 and 10332430 and my buffer is long enough and all the other parameters are good in the st...

how do I use c preprocessor to make a substitution with an environment variable

In the code below, I would like the value of THE_VERSION_STRING to be taken from the value of the environment variable MY_VERSION at compile time namespace myPluginStrings { const char* pluginVendor = "me"; const char* pluginRequires = THE_VERSION_STRING; }; So that if I type: export MY_VERSION="2010.4" pluginRequires will be se...

Dynamic memory allocation question

when you allocate dynamic memory on the heap using a pointer, char *buffer_heap = new char[15]; it would be represented in memory as: ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍýýýý««««««««þþþ why doesn't there be a NULL terminating character at the end instead of ýýýý««««««««þþþ? ...

How can I search for a specific computer over a closed network?

I have a network of 16 computers all linked to the same switch, not connected to the internet. One of the 16 computers has a small Java app running on it along with a BlazeDS server (aka it's listening on a port for a message). Currently, the other 15 "client" computers have to manually enter the "server" IP where the java app resides...

Playing MIDI out in OS X, C++

How can I send MIDI messages out from a C++ program and have them play the sound from the General MIDI bank? I've looked around and there doesn't seem to be a simple answer, and my brain starts to melt after reading long manuals about CoreMIDI and things like that. I have a simple C++ game/synthesizer project, and all I want to do is, ...

QApplication: How to shutdown gracefully on Ctrl-C

I have a QApplication that, depending on command line parameters, sometimes doesn't actually has a GUI window, but just runs without GUI. In this case, I want to shut it down gracefully if CTRL-C was hit. Basically my code looks like this: int main(int argc, char* argv[]) { QApplication app(argc, argv); ... // parse command ...

unique_ptr<> v shared_ptr<> in regards to destruction policy

I've been teaching myself the smart pointers that are part of C++0x and came across something that feels inconsistent to me. Specifically, how the destruction policy of unique_ptr<> and shared_ptr<> are handled. For unique_ptr<>, you can specialize std::default_delete<> and from then on unless you explicitly request a different destruc...

Windows Command Line History

I need to programmatically mount a WebDAV volume in Windows using C, and I think I'm going to use system() to achieve this (via the 'net use' command)... However, since net use requires that the password be written in plain text, I just wanted to make sure there's no logging of commands run in the Windows command line shell... I know in ...

Using C++ to import registry files

Hello everyone, I'm having some problems of getting the following simple code to run correctly: #include <process.h> int main( void ) { system("foo.reg"); //why does this NOT WORK?! //system("reg import foo.reg"); //why does this NOT WORK?! //system("regedit \"foo.reg\""); //why does this NOT WORK?! return 0; } ...