The simulation tool I have developed over the past couple of years, is written in C++ and currently has a tcl interpreted front-end. It was written such that it can be run either in an interactive shell, or by passing an input file. Either way, the input file is written in tcl (with many additional simulation-specific commands I have a...
I have some code within one function that I want to separate into its own function. I want to do this with as little modification to the original code as possible. Below I have written a noddy example where the code segment is simply "x += y". I want to take out that code and put it in its own function. With C I have to do this by changi...
Hi all .... I'm using a QListPickSelector in my project and the idea is that it displays a set of images, rather than a list of strings .. Now I have tried using the setIcon() function, which works, but the image displayed is very tiny .. !
Here is the output I get when I use the setIcon() function:
As you can see, the image displaye...
Hi guys,
What would be the best way to get the location of java.home in my C++ app? Right now I'm getting it from the registry but am wondering if there's a better/easier/cleaner way.
Thanks,
Serge
...
I have a very old C++ application that was being built with Visual C++ Version 7.0 when I inherited it. When I brought it forward to Visual Studio 2005, the conversion routine apparently changed the value of StackReserveSize from "0" to "66112".
I probably never would have noticed this change if it had not manifested into stack overflow...
With the following code va_arg is returning garbage for the second and third pass through vProcessType.
// va_list_test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <tchar.h>
#include <cstdarg>
#include <windows.h>
void processList(LPTSTR str, ...);
void vProcessList(LPTSTR str, va_list ar...
if for example I do:
FOO foo;
foovect.push_back(foo);
where FOO is a class with a default constructor.
Will the constructor be called only when foo is put on the stack, or is it called again when pushed into the std::vector?
Thanks
I'm doing:
OGLSHAPE::OGLSHAPE(void)
{
glGenBuffersARB(GL_ARRAY_BUFFER_ARB,&ObjectVBOInt);
}
...
I have a very strange problem when reading a binary file.
void metaDataProcess(FILE *f){
unsigned __int32 obLength;
unsigned __int32 numProp;
char* objPath;
unsigned __int32 rawDataIndex;
int level;
fread(&obLength,sizeof(obLength),1,f);
objPath=new char[obLength];
cout<<"i am at"<<ftell(f)<<endl;
fr...
I am trying to block access to the default constructor of a class I am writing. The constructor I want others to use requires a const reference to another object. I have made the default constructor private to prevent others from using it. I am getting a compiler error for the default constructor because the const reference member var...
Is there a way to make a non-resizeable vector/array of non-reassignable but mutable members? The closest thing I can imagine is using a vector<T *> const copy constructed from a temporary, but since I know at initialization how many of and exactly what I want, I'd much rather have a block of objects than pointers. Is anything like wha...
Hi,
What are some of the good tools for analysing memory (for footprint, allocation and deallocation)? I am familiar with valgrind. If there are tools apart from that, would be nice to know about them.
Best.
...
I have the need to open a file, read-lock it, then attempt to get a write lock but keep the read lock if it fails.
This works great in POSIX using fcntl locking.
In Windows I can use LockFileEx to get file locks. I can get both read and write locks (shared and exclusive).
However, it seems that in Windows I must take the exclusive wri...
hello.
I believe I had seen macro in boost that recovers template template parameters, for example:
template<class>
struct parameters;
#define parameters(T) template<class A> \
struct parameters<T<A> > { typedef A type1; };
is there one like this, or am I wrong?
Thank you
...
I have a batch file that tries to compile a static library using Borland C++ Builder 6.0
It is called from Borland make (makefile created with bpr2mak) which is called from a .bat file (used to compile the whole project with Visual Studio and some Borland C++ Builder legacy projects), which is called from a bash shell script running ins...
GCC 4.1 uses the <tr1/memory> header and GCC 4.3 uses <memory> header, I need a portable way to use shared_ptr with GCC 4.3.2 and with GCC 4.2.1, is there any way to do that without checking GCC version macros or using external libraries like Boost ?
...
Hello,
I'd like to declare a member function pointer in C++, that returns the same member function pointer type
This doesn't work:
class MyClass {
public:
typedef FunctionPtr (MyClass::*FunctionPtr)();
}
Does someone know a solution?
...
I already know there's answers for this kind of thing, but I don't really know how to implement them in my code. Also, I would like to refrain from using any more functions unless neccessary.
Here's my code:
int main()
{
unsigned seed;
seed = 1;
srand(seed);
std::string starFox[8];
int x[8];
starFox[0] = "Do a barrel roll!";
sta...
I've got Windows 7 64-bit and I just installed Qt (open-source, version 2010.04) and integrated it into Eclipse (CDT, version Helios). Everything seemed to went fine, I added paths to both Qt and mingw32 compiler and configured Qt by running configure.exe. The integration with Eclipse works fine too.
However, I've problem with the first...
I am using Layered windows and they seem to impose quite the performance penalty (one of my cores is used completely). Is there any way to tweak performance with layered windows? Is Direct2D a viable alternative? (my layered window needs to have per-pixel alpha).
thanks,
H
...
I need help with making this bit of code faster:
UnitBase* Formation::operator[](ushort offset)
{
UnitBase* unit = 0;
if (offset < itsNumFightingUnits)
{
ushort j = 0;
for (ushort i = 0; i < itsNumUnits; ++i)
{
if (unitSetup[i] == UNIT_ON_FRONT)
{
if (j == offset)
unit = unitFormation[i];
++j;
}
}
}
el...