c++

Compliation Error of a C++ second life library

Hello, I am trying to compile a slight part of second life library. Specifically, it is the llcommon part. I compiled it in Windows System with VS9. I failed and the compiler said it cannot recognize '_Ios_Openmode' as a member of 'std' The corresponding code is as following: explicit llifstream(const std::string& _Filename, std::_Ios_...

Simple Virtual Filesystem in C/C++

Hi I would like to implement a very simple Virtual Filesystem (VFS) which supports some basic file system operation like fwrite, fopen, fput, etc. The VFS is an abstraction layer on top of some concrete OS, e.g. Windows, Linux etc. Assume now, that the fopen interface looks something like this FILE VFS_File_Open( const unsigned char* s...

Const Overloading: Public-Private Lookup in C++ Class

The following code does not compile, saying " error C2248: 'A::getMe' : cannot access private member declared in class 'A'". Why? I am trying to call the public interface. class B { }; class A { public: const B& getMe() const; private: B& getMe(); }; int main() { A a; const B& b = a.getMe(); return 0; } ...

Compile simple string

Hello All, Was just wondering if there are any built in functions in c++ OR c# that lets you use the compiler at runtime? Like for example if i want to translate: !print "hello world"; into: MessageBox.Show("hello world"); and then generate an exe which will then be able to display the above message? I've seen sample project around ...

naming convention of temp local variables

What is the standard way to name a temp variable in the local function? let me give you an illustration of what I am doing. I get a pointer to a structure, so I want store one of its members locally to avoid a de-referenced, and then any modification assign back to the pointer. To be more concrete: struct Foo { double m_d; }; vo...

Is the C++ STL std::set thread-safe?

I've a question about the thread safety of std::set. As far as I know I can iterate over a set and add/erase members and that doesn't invalidate the iterators. But consider following scenario: thread 'A' iterates over a set of shared_ptr<Type> thread 'B' occasionally adds items to this set. I've experienced segfaults as the program...

[C++] Registering class instances for to be controlled by a class's function

Hello there, Hehe I'm having hard time on choosing the question title. But let me explain about my problem to make it clearer. I'm now writing my own GUI library for my game in C++ with a DirectX wrapper out there. But I got no idea on how to render my in-game windows by just calling the "manager" class's draw function. For example, s...

LISP Parser C++

Is there an existing LISP parser written in C++? I just want the parser, not a full interpreter, but an interpreter to go along with it would be a plus. ...

What is the mechanism through which destructors are called for stack-assigned objects?

How does C++ ensure that destructors are called for stack assigned objects? What happens to the destructor function (or a pointer to it) when I assign dynamic memory as follows: class MyClass { public: ~MyClass() { std::cout<<"Destructor called."<<std::endl; } MyClass() { std::cout<<"Constructor called."<<std::endl...

print in Xcode GDB with C++ doesn't print correct values

I'm writing/debugging an iPhone project that uses a large portion of C++ for image processing. I'm having trouble when I'm using gdb under Xcode because whenever I print values, they are completely out of whack with the true values (comparing cout << "width" << width << endl; prints out 320, and if I do a print width in gdb, I g...

Problem synchronizing QThreads

Apart from main thread, I've ThinkerThread object _thinker whose finished() signal is connected to main thread's slot: connect(&_thinker, SIGNAL(finished()), this, SLOT(autoMove())); The slot autoMove() causes _thinker to initialize and run again: _thinker.setState(/* set internal variables to run properly */); _thinker.start(); Th...

[Boost BGL] reducing memory requirements for adjacency list

Hi, I'm using adjacency_list< vecS, vecS, bidirectionalS ... > extensively. I have so many graphs loaded at once that memory becomes an issue. I'm doing static program analysis and store the callgraph and flowgraphs of the disassembled binary in boost graphs. Thus I can have several ten thousand functions==flowgraphs and one gigantic ca...

C Runtime Library Version Compatibility: updates require rebuilds?

How do you construct a library (static lib or a dll/so) so that it isn't sensitive to future updates to the system's C runtime librarires? At the end of July, Microsoft updated a bunch of libraries, including the C runtime libraries. Our app is written with a mix of MFC/C++/VB and some third party libraries, including some that are clos...

Is a public constructor in an abstract class a codesmell?

Is a public constructor in an abstract class a codesmell? Making the constructor protected provides all of the access of which you could make any use. The only additional access that making it public would provide would be to allow instances of the class to be declared as variables in scopes that cannot access its protected members, but ...

Binary Reproducibility in Visual C++

Is there a way to force the same code to produce the same binary in Visual C++? Turn off the timestamp in the PE or force the timestamp in the PE to be some fixed value, in other words? ...

What to learn first - C++/STL/QT or .NET/C# - if I have limited time while learning and working?

I am currently a CS student at a 4th year(of total 5). I`m studying and working. At work I use ASP.NET. So, while working and studying, I have not so much time to learn new languages and techniques. What do you suggest to learn first - C++/STL/QT or C#/LINQ/WPF? I mean, C++ and its libraries are stable and do not change as fast as .NET t...

Visual C++ math.h bug

Hello! I was debugging my project and could not find a bug. Finally I located it. Look at the code. You think everything is OK, and result will be "OK! OK! OK!", don't you? Now compile it with VC (i've tried vs2005 and vs2008). #include <math.h> #include <stdio.h> int main () { for ( double x = 90100.0; x<90120.0; x+=1 ) { ...

Is it safe to call CFRunLoopStop from another thread?

Hi all, The Mac build of my (mainly POSIX) application spawns a child thread that calls CFRunLoopRun() to do an event loop (to get network configuration change events from MacOS). When it's time to pack things up and go away, the main thread calls CFRunLoopStop() on the child thread's run-loop, at which point CFRunLoopRun() returns in...

Performance problems when scaling MSVC 2005's operator<< accross threads.

When looking at some of our logging I've noticed in the profiler that we were spending a lot of time in the operator<< formatting ints and such. It looks like there is a shared lock that is used whenever ostream::operator<< is called when formatting an int(and presumably doubles). Upon further investigation I've narrowed it down to this ...

How to get the entry point of a child process?

I created a child process from within my process with CreateProcess() (in C++) I then continue on using ReadProcessMemory to read through the memory and search for a specific something. I would like to start my search from the entry point of that process , since the process is loaded into it's own virtual space I have no idea at this po...