I was going through a re-entrancy guide on recommended practices when writing re-entrant code.
What other references and resources cover this topic?
What lint-like tools can be used to check for these issues?
...
I have a library that consists of three parts. First is native C++, which provides the actual functionality. Second is a C++/CLI wrapper/adaptor for the C++ library, to simplify the C# to C++ transition. Finally I have a C# library, which invokes the C++ library through the C++/CLI adaptor.
Right now there I have two sets of parallel...
hello, I have this snippet of the code:
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
};
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
setFixedSize(200, 120);
QPushButton *quit = new QP...
I have string data representing locales, like "fr" or "en". I need to convert it to the appropriate LCID values, like 0x80c or 0x409. Is there a function or macro to do so?
I'm using C++ on Windows 7.
...
I'm making some win32 string API calls and am assuming that the strings come out as wide strings, which is valid on XP and newer. How can I assert this? Is this a runtime check or a compile-time check?
Am I doing it wrong? Here's an example:
typedef std::basic_string<TCHAR> TString;
inline TString queryRegStringValue(HKEY key, const TS...
How can I accomplish what is suggested by the following?:
template<typename T>
class Base{...};
...
class Derived : public Base<int>{...};
...
(Question is related to my previous questions here, here, here, and here).
I am maintaining a very old application that was ported years ago from DOS to Windows, but a lot of the old C conventions still carry forward.
The one particular convention is a setBit and clrBit macro:
#ifndef setBit
#define setBit(word, mask) word |= mask
#en...
I initially started out using a std::multimap to store many values with the same key, but then I discovered that it doesn't preserve the insertion order among values with the same key. This answer claims it can be done with boost::multi_index::multi_index_container, but gives no example. Looking through the docs, there are no examples ...
Hi,
I have a c++ program that dies because of out of memory error.
Do you know a tool for c++ program that shows which program line allocated how much heap?
I would like to figure which part of the program consumes most of the heap.
Thanks.
Platform: Microsoft C++...Windows
By the way, can heap corruption cause excessive memory usage?...
I want to learn some basics of software design (with the idea to expand thereupon later), particularly for mac and mobile devices. I am new to programming and have only basic HTML experience, so pretty much a complete novice. Are there any suggestions as to where I should start? I have just bought Herb Schildt's beginner's guide to C+...
Hi all,
I have a code that runs on an embedded system and it has to run really fast. I know C and macros, and this particular project is coded mostly in C but it also uses C++ templates [increasingly more]. There is an inline function:
inline my_t read_memory(uint32 addr) {
#if (CURRENT_STATE & OPTIMIZE_BITMAP)
return readOptimiz...
I have this:
using namespace boost::numeric::ublas;
matrix<double> m (3, 2);
int k = 0;
for (int j = 0; j < m.size1 (); j++) {
for (int i = 0; i < m.size2 (); i++)
m (j, i) = k++;
}
m =
0 1
2 3
4 5
And I need to append another matrix m2 to m
matrix<double> m2 (3, 1);
k = 0;
...
I'm reading through an example in primer and something which it talks about is not happening. Specifically, any implicit shallow copy is supposed to copy over the address of a pointer, not just the value of what is being pointed to (thus the same memory address). However, each of the pos properties are pointing to two different memory ad...
How would I write a function to add up the content of each row in a 2D array? To add the contents of each column?
my code (so far):
#include <iostream>
using namespace std;
const int QUARTER = 4;
void getdata(float [][QUARTER], int);
void displaydata (float [][QUARTER], int);
void quartertotal(float [][QUARTER], int);
int main()
{
...
Hi,
I am reading data from a (serial) port using a non-blocking read() function (in C/C++).
This means the data comes-in in chunks of undetermined (but reported) sizes (incl. 0) each time I "poll" the port. I then need to parse this "stream" for certain patterns (not XML).
My naive implementation concatenates the new string to the pre...
Hi.
I'm working on a game engine and in an earlier question it was suggested that I start using boost::ptr_vector to maintain a list of pointers.
The basic idea is to have several State's, each State has a SceneGraph. Each state has several resources that they initialize, and then stuff its own SceneGraph. The SceneGraph has a boost::p...
When linking an executable, if it does not make reference to any of the symbols in one of the DLLs on the link line, will it still depend on that DLL at runtime?
To make the question concrete, suppose I am building an application from Visual Studio project foo.
Under Project Properties > Linker > Input > Additional Dependencies I have ...
I chopped down my make file so I can compile a C++ program with very few, but some flags set to see if I can determine if they are working. The following is my make file section on C++ flags:
# Common compiler flags
CFLAGS = -mips1 -Wa,-non_shared \
-mno-abicalls \
-I. -I$(SESCSOURCEDIR)/src/libapp \
-I$(SESC...
I am currently using select() to act as a timer. I have network receive operations which occur within a loop, and every few seconds a processing operation needs to occur.
As a result, the select() statement's timeout constantly changes -- decreasing to zero over time and then restarting at 3.
rv = select(selectmonitor+1, &readnet, NULL...
I'm modifying someone else's code which uses TCHAR extensively. Is it better form to just use std::wstring in my code? wstring should be equivalent to TString on widechar platforms so I don't see an issue. The rationale being, its easier to use a raw wstring than to support TCHAR... e.g., using boost:wformat.
Which style will be more c...