OK, the question title is a bit crappy, but I didn't really know how to phrase this better.
The problem I have is that given a std::vector<T> vs. a T* + size_t count my compiler (Visual Studio 2005 / VC++ 8) will actually generate worse code when looping over the pointer than when looping over the vector.
That is, I have a test struct ...
I'm currently writing a set of wrapper functions of Qt4 for an application as plugin (because I personally think that writing extensions in plain C is easier to accomplish).
At first I though this could be done by simply abstracting the following:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QA...
I have a makefile as follows:
CC = gcc
CFLAGS = -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" $(INCLUDES)
ifdef DEBUG
CFLAGS += -g3
endif
INCLUDES = \
-I../config.include \
-I../log.include \
-I../services.include
SRC_DIR = src
BIN_DIR = bin
BINARY = report
SRCS = $(shell ls $(SRC_DIR)/*.cpp)
OBJS = $(SRCS:%.cpp=%....
and how can I do it in C++?
...
Hi,
I am trying to print a wstring/wchar_t in xcode to the console but unfortunatelly it only works with basic chars (i think ascii) chars, everything else gets displayed in numbers, for instance the following:
std::cout << "äöüu"<< std::endl;
std::wcout << L"äöüu" << std::endl;
while the cout version prints "äöüu" as expected I get t...
My research group uses a Wordpress blog. Frequently I want post snippets or even entire short programs I've been working on to it, with most of my code being written in C/C++ or scripting languages (Bash, TCL, etc).
I figure that there have to be some good extensions to Wordpress to colorify code since so many people use it. I'm loo...
In C++, is it possible to call a function of an instance before the constructor of that instance completes?
e.g. if A's constructor instantiates B and B's constructor calls one of A's functions.
...
I am trying to define a constructor for an explicitly specialized class template outside the class definition, as so:
template <typename T>
struct x;
template <>
struct x<int> {
inline x();
/* This would have compiled:
x() {
}
*/
};
template <> // Error
x<int>::x() {
}
But it seems to be an error. Comeau says...
I'm using the new Boost 1.44.0 MSM library to produce a state machine. In this state machine there are two classes of events class1 and class2. class1 events can be processed by either states S1 or S2 while class2 events can only be processed by state S2.
A special class1 event upgrade_req requests an upgrade from state S1 to state S2....
I have a vector to hold objects of a bullet class. Is this the correct way to add bullets to the vector structure?
std::vector<Bullet> bullets;
Bullet newbullet(thisPlayer.x+PLAYERSPRITEWIDTH,(thisPlayer.y-(PLAYERSPRITEHEIGHT/2)));
bullets.push_back(newbullet);
I don't think the bullets get added this way.
...
For an application that uses a number of environment variables, is there some kind of a convention or "best practice" when it comes to grabbing environment variables and putting them into either a struct or a bunch of const's? Obviously, I want to fallback to a default value for each and every environment variable. Right now, using the f...
I have a c++ object that accepts sound requests and plays them with ALSA. There is thread that processes the sound requests. Some sounds are periodic and are rescheduled after the wav file contents have been written to the ALSA library. Is there a way I can find out when all the data has been played? The function snd_pcm_writei is a bloc...
I am attempting to delay load wintrust.dll and crypt32.dll in my application (these are used to perform digital signature/publisher checks in a DLL). I am using VS2008. After adding these two DLLs as entries in the Delay Load property in the Linker section of my project properties, I still get LNK4199 warnings that nothing was loaded fro...
A co-worker posted this on an MS forum but was not able to get an answer.
He's using Win7, VS 2008 (C++) pro - not the express version.
When he selects Tools->Attach to Process the dlg box with the dropdown for "Transport" shows only "default" and the Qualifier field is greyed out and only shows his machine name.
He wants to debug...
I must have missed something with the boost::recursive_wrapper thing, I always get an error:
error: no matching function for call to 'boost::tuples::tuple, std::allocator >, client::compare_attr_op_t, std::basic_string, std::allocator >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null...
Hi, gang. First, a high-level description of the problem & approach.
I have a list containing images and pixel locations in each image - a list of lists. I want to pick n items at random from that list of images and for each image I want to iterate over k random pixel locations. I want to do this in parallel. For each processed pixel, I...
Hello, I am running into a little pickle. For class I have an assignment (below), I came up with a solution but I keep getting an error, that says;
"'factorial' : recursive on all control paths, function will cause runtime stack overflow;"
If someone could help me, I've been working on this for about an hour and I'm stumped!
Assi...
Project1: A C++ EXE project with code
generation option "runtime library" set to
"Multithreaded Debug Dll".
Project2: A C# EXE project developed
with .Net Version, say, 3.5
Suppose I want to write an installer project for these projects. I naturally include their primary outputs (the exe's) in the installation package. But the exe's a...
I am trying to run my C++ program on other Mac OSX machines which may have an older copy of libstdc++, but have all the other tools. I tried to follow this approach, also mentioned in this SO question, even though it discusses a linux setup. I have small program try.cpp:
#include <iostream>
int main() {
int a = 10;
std:...
The Win32 API has a PostMessage function that posts a message to the end of the GUI message queue to be processed later from the GUI thread, as opposed to SendMessage which sends and processes the message synchronous with the calling thread.
Is there a Qt solution for PostMessage functionality? A coworker suggested that Qt's server/sock...