c++

What c++ features should be avoided for embedded development

I'm interested in compiling a list of c++ features that are not advisable for use in embedded systems (and which may cause people to recommend c over c++). Please try to add why if you know, or add your why to others' answers. Here's one for a start (the only one I know) Dynamic polymorphism, don't know why, but someone said it's "co...

An example of an embedded project for a single person

I've been trying to wrap my head around embedded. Since I will be self-taught in this specific niche, I realize it will be harder to get a job in the field, so I'm hoping to add a completed project to my resume to prove to potential employers that I've done it and can do it again for them. Can someone suggest a project that I can undert...

Why can CImg achieve this kind of effect?

The compilation is done on the fly : only CImg functionalities really used by your program are compiled and appear in the compiled executable program. This leads to very compact code, without any unused stuffs. Any one knows the principle? ...

Rounding to nearest number in C++ using Boost?

Is there a way to round to the nearest number in the Boost library? I mean any number, 2's, 5's, 17's and so on and so forth. Or is there another way to do it? ...

Why should files be mounted in Linux

Hello, I got an old library which does some manipulation with files on floppy\ CD (transferring the files on network paths). This library has a thread which checks on each second whether the file (e.g. the floppy diskette\ the CD disk) is mounted. Why? What operations can be done only on mounted files? Thanks a lot. ...

Sending parameters to a DLL to be boost::bind'ed

I have a DLL which has a function which accepts a function pointer converts it to a boost::function. This is then stored and then called from inside the DLL. I want to add a function to the DLL to handle member functions in a similar way. I know I need to use boost::bind to wrap the member function pointer and the object together. I wan...

Input terminal problems and map

I am using map to count the occurence of words. Here is the code. #include <iostream> #include <map> #include <string> using namespace std; int main() { map<string,int>wordcount; string s; while (cin>> s && s!="red") ++wordcount[s]; while (cin>>s && s!="red") cout << s << " " << wordcount[s] << endl; ...

Redrawing QGLWidget with 3D+2D graphics

Hi, I have a QGLWidget which draws both 3D and 2D graphics (just like in Qt's overpainting example). The thing is after I added drawing 2D graphics (moved code from paintGL() to paintEvent(), etc.), the widget stopped redrawing most of the times. It didn't redraw after resiging, after loading, and so on. So I put repaint() calls, it he...

USB serial verification in C++

Hi, I have a DLL which I intend to send to a 3rd party and I'd like to protect it by restricting it to run only if a specific USB device is connected. I'm using the setupapi to get the device's serial number (by calling SetupDiGetDeviceInstanceId()). I would like to make the verification hard to track in case someone disassembles the DL...

Is there an equivalent to python's urllib in c/c++ ?

any c/c++ library out there that provides functions like getUrl, urlopen, post etc. ? ...

C aliasing rules and memcpy

While answering another question, I thought of the following example: void *p; unsigned x = 17; assert(sizeof(void*) >= sizeof(unsigned)); *(unsigned*)&p = 17; // (1) memcpy(&p, &x, sizeof(x)); // (2) Line 1 breaks aliasing rules. Line 2, however, is OK wrt. aliasing rules. The question is: why? Does the compiler have special...

Audio detection in an embedded system

I'm getting started with embedded, and was thinking to start learning by implementing some sort of a clapper project where I detect audio and respond to it. I have some specific questions, but since I'm new to this field, please add any additional advice What audio libraries exist that could help with this type of project What hardwa...

question about map sort

for example we have map map<char,int>mymap; mymap['a']=101; mymap['c']=45; mymap['b']=76; mymap['d']=98; i know that if we iterate through map it will print element according to following way a>=101; b>=76; c>=45; d>=98; how do such that small keys refer small values? or a-45 b-76 c-98 d-101 ? thanks ...

Architectural C++/STL question about iterator usage for O(1) list removal by external systems.

This is a pretty straightforward architectural question, however it's been niggling at me for ages. The whole point of using a list, for me anyway, is that it's O(1) insert/remove. The only way to have an O(1) removal is to have an iterator for erase(). The only way to get an iterator is to keep hold of it from the initial insert() or t...

What is the explicit keyword for in c++?

Possible Duplicate: What does the explicit keyword in C++ mean? explicit CImg(const char *const filename):_width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) { assign(filename); } what's the difference with or without it? ...

Are there specialities within the embedded fields

I've started learning embedded and its 2 main languages (c and c++). But I'm starting to realize that despite the simple learning requirements, embedded is a whole world in and of itself. And once you deal with real projects, you start to realize that you need to learn more "stuff" specific to the hardware used in the device you're worki...

Anyone knows what `cimg::exception_mode() = 0;` does?

const unsigned int omode = cimg::exception_mode(); cimg::exception_mode() = 0; Never see this kinda syntax before. ...

Why can the code between ifndef/endif still get run here?

#define cimg_use_jpeg 2 #ifndef cimg_use_jpeg //code goes here #endif I really don't understand... ...

QT: Is it a good idea to base my domain objects on QObject?

Hi, I'm reasonably new to using the QT framework in combination with C++. I was wondering: Is it a good idea to base my domain classes on QObject? Or should I only do this for classes higher up in the hierarchy? (closer to the user interface level). The QT documentation isn't clear on this: Taken from the QT documentation: The meta...

Disable Window Resizing Win32

how do I disable resizing by dragging the edge of windows? Here is my window creation code bool CreateGLWindow(char* title, int width, int height) { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // W...