c++

boost::system::(...)_category defined but not used

I'm currently getting compiler warnings that resemble the warning I gave in the question title. Warnings such as.... warning: 'boost::system::generic_category' defined but not used warning: 'boost::system::posix_category' defined but not used warning: 'boost::system::errno_ecat' defined but not used warning: 'boost::system::native_ec...

parsing argc and argv in c++

I want to learn more C++... Usually I make a for loop to parse argv, and I wind up with a bunch a C-style strings. I want to do something similar in C++, but preferably without reading from /proc/whatever. At first, I tried to convert the C-style string to a C++ style string without results... The frustrating bit is that everyone on SO...

C++ header file convention

I am working on a small game using C++, and I used Eclipse CDT's class generator. It created a .h file with the class definitions and a .cpp file that included body-less methods for said class. So if I followed the template, I'd have a .cpp file filled with the methods declarations, and a .cpp file with method bodies. However, I can't ...

Using tui option of GDB

Hi All, I am currently working with NS-2(A network Simulator) and I wanted to use the tui option of gdb such that i can view the course code while debugging. (Just like Visual studio) As of now the source window is blank when i run "gdb -tui" . However I can see the file when i do a "list" in gdb, but I am not able to make it go autom...

Does my C++ compiler optimize my code?

While using modern C++ compilers (including MSVC, GCC, ICC), how can I say if it has: parallelized the code vectorized the loops (or used other specific processor instructions) unrolled the loops detected tail-recursion performed RVO (return-value optimization) or optimized in some other way without diving into the assembler code the...

Convert from hexadecimal to binary C++

This kind of builds up on Already asked question... However here, say, I'm given a hexadecimal input which could be a max of '0xFFFF' I'll need it converted to binary, so that I'd end up with a max of 16 bits. I was wondering if using 'bitset' it'd be quite simple.. Any ideas? EDIT : After getting answers, improvised piece of code he...

Problem with iterators for std::list of boost::shared_ptr

Hi, I'm having a problem with the following code: #include <list> #include <boost/shared_ptr.hpp> #include "Protocol/IMessage.hpp" template <typename HeaderType> class Connection { public: typedef IMessage<HeaderType> MessageType; typedef boost::shared_ptr<MessageType> MessagePointer; template <typename Handler>...

Never ending Win32 Message loop

I have the following code: MSG mssg; // run till completed while (true) { // is there a message to process? while(PeekMessage( &mssg, NULL, 0, 0, PM_REMOVE)) { // dispatch the message TranslateMessage(&mssg); DispatchMessage(&mssg); } if(mssg.message == WM_QUIT){ break; } // our stuff will go here!! Render(); listeners...

Tips / Examples on sending an Image file (jpeg, png) over socket programming?

I've heard that we can somehow send an image file with binary over a socket... But I have no idea on how to convert an image file into binary or how to even think of sending it over a socket... Was hoping if someone could post a simple example? or point me in the right direction :) I am also using QT for just my gui, but not using QT so...

Is it possible to see definition of Q_SIGNALS, Q_SLOT, SLOT(), SIGNAL() macros? (Qt)

Is it possible to see definition of Q_SIGNALS, Q_SLOT, SLOT(), SIGNAL() macros in Qt framework? P.S. Google gave me nothing in this question. ...

C++ bindings to jGoodies?

Thus far the best C++ UI libraries I've run into are Qt, GTK, and wxWidgets; Are there existing libraries similar to jGoodies or 'better'. I am interested in mature (yet simple) technologies. ...

Overhead of a Memory Barrier / Fence

Hi, I'm currently writing C++ code and use a lot of memory barriers / fences in my code. I know, that a MB tolds the compiler and the hardware to not reorder write/reads around it. But i don't know how complex this operation is for the processor at runtime. My Question is: What is the runtime-overhead of such a barrier? I didn't found ...

How do I convert an image into a buffer so that I can send it over using socket programming? C++

How do I convert an image into a buffer so that I can send it over using socket programming? I'm using C++ socket programming. I am also using QT for my Gui. Also, after sending it over through the socket, how do I put that image back together so it can become a file again? If someone could put up some sample code that would be great ...

error C4430: missing type specifier / error C2143: syntax error : missing ';' before '*'

I am getting both errors on the same line. Bridge *first in the Lan class. What am i missing? #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; class Lan{ Bridge *first; Bridge *second; Host hostList[10]; int id; }; class Bridge{ Lan lanList[5]; }; class Host{ Lan * lan; ...

C# & C++: "Attempted to read or write protected memory" Error

The following code compile without errors. Basically, the C#2005 Console application calls VC++2005 class library which in turn calls native VC++6 code. I get the following error when I run the C#2005 application: "Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indicat...

How to get emacs tempo mode working with abbrevs for C/C++?

I've been experimenting with emacs tempo mode and it seems likely to save me lots of typing (always a good thing), but I haven't gotten it to work exactly the way I want it. On the wiki, there is an example for elisp similar to what I want to do which works as expected. Here is the complete .emacs that I tested it on: (require 'tempo)...

Problem with a volumetric fog in OpenGL

Good day. I am trying to make a volumetric fog in OpenGL using glFogCoordfEXT. Why does a fog affect to all object of my scene, even if they're not in fog's volume? And these objects become evenly gray as a fog itself. Here is a pic Code: void CFog::init() { glEnable(GL_FOG); glFogi(GL_...

How to let omnicppcomplete automatically close empty argument lists?

Is it possible to let Vim's omnicppcomplete automatically close argument lists for functions or methods that do not take any arguments? For example, assuming v is an STL vector, when auto completing v.clear(), we end up with: v.clear( It would be nice if the closing parenthesis would be automatically added. Is this possible? ...

What next generation low level language is the best bet to migrate the code base ?

Let's say you have a company running a lot of C/C++, and you want to start planning migration to new technologies so you don't end up like COBOL companies 15 years ago. For now, C/C++ runs more than fine and there is plenty dev on the market for it. But you want to start thinking about it now, because given the huge running code base a...

How to properly return reference to class member?

Hi, suppose this class: class Foo { protected: QPoint& bar() const; private: QPoint m_bar; }; QPoint& Foo::bar() const { return m_bar; } I get this error: error: invalid initialization of reference of type ‘QPoint&’ from expression of type ‘const QPoint’ However it works if I change it to this: QPoint& Foo::b...