Is there a way to identify at run-time of an executable is being run from within valgrind? I have a set of C++ unit tests, and one of them expects std::vector::reserve to throw std::bad_alloc. When I run this under valgrind, it bails out completely, preventing me from testing for both memory leaks (using valgrind) and behavior (expecti...
This is weird. It is a trivial problem:
A std::string with bits with length multiple of 8, the first 8 is: "10011100".
//Convert each 8 bits of encoded string to bytes
unsigned char c = 0;
for(size_t i = 0; i < encoded.size(); i += 8)
{
for(size_t k = 0; k < 8; k++)
{
c <<= k;
if(encoded.at(i + k) == '1') c += 1...
Ive been playing around with XAudio2 but have encountered some strange problems with the mmioOpen function
For some reason it seems to fail with MMIOERR_FILENOTFOUND, even though the file is there, in fact the file is in the same directory as other files I'm loading which work fine...
The wav files im using to test with are just the on...
When I try to build my project I get the following message in the build window :
========== Build: 0 succeeded or up-to-date, 0 failed, 1 skipped ==========
I tried rebuilding , then building again , but it doesn't help . Is there a way to view more detailed messages ? The "skipped" part doesn't give me any info on what's wrong . I am ...
What is the accepted/most commonly used way to manipulate dynamic (with all dimensions not known until runtime) multi-dimensional arrays in C and/or C++.
I'm trying to find the cleanest way to accomplish what this Java code does:
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int rows=sc.nextInt();
int co...
Curious to get people's thoughts. I conduct frequent interviews, and have had enough in my career to reflect on them, and I've noticed a broad array of questions. I made this c++ specific, but it's worth noting that I have had people ask me algorithmic complexity questions over the phone, and I don't even mean what is the complexity of a...
I know how they are different syntactically, and that C++ uses new, and C uses malloc. But how do they work, in a high-level explanation?
See http://stackoverflow.com/questions/240212/what-is-the-difference-between-newdelete-and-mallocfree#240308
...
What is a good C/C++ CSS parser? All that I can find is CSSTidy, and it seems to be more of an application than a parsing library.
...
I am writing a high performance system in portable modern c++. A lot of STL and Boost. I'd like to start building some front ends to this system. Ordinarily I would opt to use a non c++ solution to a UI, however this is meant to be a very high performance UI, meaning low latency to respond to messages, high volume of messages to sort and...
I have the following bit of legacy C++ code that does not compile:
#include <stdio.h>
#include <iostream>
extern ostream *debug;
GCC (g++) complains: "expected initializer before ‘*’ token"
Looking around it seems more common to declare these as external references, like this:
extern ostream& debug;
Why is a pointer not valid, bu...
I am not understanding the point of using .def files with DLLs.
It seems that it replaces the need to use explicit exports within your DLL code (ie. explicit __declspec(dllexport)) however I am unable to generate a lib file when not using these which then creates linker issues later when using the DLL.
So how do you use .defs when lin...
So I am doing a lot of high performance network programming using Boost::Asio (or just Asio if you will), and have a pretty solid grasp of the essentials of both TCP and UDP protocols. I am wondering though, because I still don't consider myself an expert in networking despite my knowledge, what is a good way to frame the essentials of w...
Which is the best book on Data structures to refer to?
...
I write this tiny C++ example in Eclipse 3.4.1 (CDT 5.0.1):
#include <iostream>
#include <vector>
#include <boost/foreach.hpp>
int foo()
{
std::vector<int> numbers;
BOOST_FOREACH(int n, numbers)
{
std::cout << n << std::endl;
}
std::cout << numbers.size << std::endl;
}
Then I hit Shift+Ctrl+F to format my code, and it b...
I need to use lists for my program and needed to decide if I use std::vector or std::list.
The problem with vector is that there is no remove method and with list that there is no operator []. So I decided to write my own class extending std::list and overloading the [] operator.
My code looks like this:
#include <list>
template <clas...
In my C++ program (on Windows), I'm allocating a block of memory and can make sure it stays locked (unswapped and contiguous) in physical memory (i.e. using VirtualAllocEx(), MapUserPhysicalPages() etc).
In the context of my process, I can get the VIRTUAL memory address of that block,
but I need to find out the PHYSICAL memory addres...
I'd like to create an abstraction in OpenGL of the environment settings(blending, stenciling, depth, etc.) that works like the matrix stack. Push onto the stack, make any changes you need, draw your objects, then pop the stack and go back to the prior settings.
For example, currently you might have drawing code like this:
glEnable(GL_B...
Can I convert a bitmap to PNG in memory (i.e. without writing to a file) using only the Platform SDK? (i.e. no libpng, etc.).
I also want to be able to define a transparent color (not alpha channel) for this image.
The GdiPlus solution seems to be limited to images of width divisible by 4. Anything else fails during the call to Save()....
Hello,
I am a 10year+, C++ linux/windows developer and I have been asked to estimate the effort to port the windows application to OS X.
I haven't developed on OS X before,so I don't know what to expect.
It is a C++/Qt application, so I want to ask: what are the de facto tools like editor, IDE, compiler, make tool, etc ? Which tools a...
Hi,
how do I bind a std::ostream to either std::cout or to an std::ofstream object, depending on a certain program condition? Although this invalid for many reasons, I would like to achieve something that is semantically equivalent to the following:
std::ostream out = condition ? &std::cout : std::ofstream(filename);
I've seen some e...