c++

Cross-platform compiling of a Qt application

I have written a C++ application that uses the Qt framework. I would like to make this application available on different platforms. Since I use Linux, I have no problems compiling the code for Linux. The questions is: Can I compile my code in such a way that it will run on Windows, Mac, etc.? As said above, I'm working on a Linux mach...

Can I expand #include files inline and not expand directives?

I'm trying to simplify the deployment of an application. In order to build the final application on an end-user's machine, a couple of C files need to be compiled. This means that dozens of header files need to be shipped along with the application. I'd like to be able to pre-include the contents of the include files, but I also need ...

Loading Preferences in to a Mac Kernel Extension

Greetings! I am working on a kernel extension driver for OSX. It is a simple keyboard filter. I have preferences that are set through a preference pane regarding how this filter will act. I need to take the preferences from this preference pane and load them in to the kernel extension. I have googled all over and haven't found anything...

C++ vector push_back() overwrites on another vector of the same type?

I defined a class named nth_best_parse this way: class nth_best_parse { public: int traversal; int nth_best_active; int nth_best_passive; double viterbi_prob; nth_best_parse(); nth_best_parse(int t, int nbl, int nbr, double v) {traversal = t; nth_best_active = nbl; nth_best_passive ...

In C++ how do i validate a file or folder path?

A user input string for a destination path can potentially contain spaces or other invalid characters. Example: " C:\users\username\ \directoryname\ " Note that this has whitespace on both sides of the path as well as an invalid folder name of just a space in the middle. Checking to see if it is an absolute path is insufficient because...

Using vb.net dll in unmanaged c++ project

I created a vb.net dll called "WSdll.dll". I compiled it, created a type library (tlb), and registered it globally(gacutil).. It includes a file called wsutils.vb, which includes a namespace called "wsutils". In the namespace, there's an interface (with attribute) called "IWSconnection", and a class called "WSconnection". The interface ...

Double Buffering for Game objects, what's a nice clean generic C++ way?

This is in C++. So, I'm starting from scratch writing a game engine for fun and learning from the ground up. One of the ideas I want to implement is to have game object state (a struct) be double-buffered. For instance, I can have subsystems updating the new game object data while a render thread is rendering from the old data by guar...

How can I make QtCreator compile multiple cpp and header files?

Hi, I have a function implemented in a cpp file and declared in header file. In the main program cpp file I include the header file and use the function. However this fails to link (undefined reference to myFunc). What do I have to change to get it working? EDIT: pro file: SOURCES += as241.c \ main.cpp \ normalvar.cpp \ no...

How to determine if binary is stripped on Mac OS X?

On Linux if I do file foo, and assuming foo is a binary or shared library, the output will show me if the binary is stripped of symbols. When I try the same on Mac OSX, all I get "Mach-0 executable ppc". Is there another command I can use to check if files are stripped? ...

In C++ can you extend a parameterized base class with different parameter value in the child class?

In all the languages that I understand this is not possible but someone was telling me it was possible in C++ but I have a hard time believing it. Essentially when you parameterize a class you are creating a unique class in the compilation stage aren't you? Let me know if I am not being clear with my question. Here is my attempt at ex...

OOLua compile errors

Code #include <OOLua/oolua.h> class foo { public: int bar(); }; OOLUA_CLASS_NO_BASES(foo)//class has no bases OOLUA_NO_TYPEDEFS OOLUA_MEM_FUN_0(int,bar) OOLUA_CLASS_END Compiler output main.cpp(21) : error C2061: syntax error : identifier 'bar' main.cpp(22) : error C2143: syntax error : missing ';' before '}' main.cpp(22) ...

Closures in C++

Hi all, I've found myself in a strange place, mentally. In a C++ project, I long for closures. Background. There's a Document-type class with a public Render method which spawns a deep call tree. There's some transient state that only makes sense during rendering. Right now it resides in the class like regular member variables. However...

c++ std::pair, std::vector & memcopy

Hi! is it safe to memcopy myvect.size()*sizeof(foo) bytes from the memoryadress of the first element of a std::vector<std::pair<T1, T2> > myvect into an array of struct foo{ T1 first; T2 second; } if the array is allocated with the same number of elements as the vector's size? thanks ...

Compiler can't find structures, what should i be including.

UPDATE: I thought it was Windsows.h i need to include and you have confirmed this, but when i do include it i get a bunch of messages like the following... 1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(5934) : error C2872: 'IDataObject' : ambiguous symbol 1> could be 'C:\Program Files\Microsoft SDKs\Windows\v6....

Qt Application: Simulating modal behaviour (enable/disable user input)

I am currently working on an application that launches separate processes which display additional dialogs. The feature I am trying to implement is simulating modal behavior of these dialogs. More specifically, I need the application to stop processing all input, both mouse and keyboard, when the dialog is launched, and resume when it's ...

Is there a way to stop a boost::signal from calling its slots if one of them returns true?

Hello, I am using the boost library and my question is about boost::signals. I have a signal that might call many different slots but only one slot will match the call so I want this particular slot to return true and that the calling will stop. Is it possible? Is it efficient? Can you guys suggest me a better way to do it if it's not ef...

Explanation required for BITCOUNT macro

Can someone explain how this works? #define BX_(x) ((x) - (((x)>>1)&0x77777777) \ - (((x)>>2)&0x33333333) \ - (((x)>>3)&0x11111111)) #define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255) Clarification: Ideally, the...

undefined reference to `pthread_mutex_trylock'

I have the following test program. #include <iostream> #include <cstdlib> using namespace std; pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER; int main(int argc, char *argv[]) { int iret; iret = pthread_mutex_trylock( & mymutex ); cout << "Test2 !!! " << endl; pthread_mutex_unlock( & mymutex ); return EXIT_SUCCESS; ...

specialize a member template without specializing its parent

I have a class template nested inside another template. Partially specializing it is easy: I just declare another template< … > block inside its parent. However, I need another partial specialization that happens to specify all its local template arguments. This makes it into an explicit specialization. Explicit specializations, for wha...

std::string in struct - Copy/assignment issues?

Suppose I have a struct containing a std::string, like this: struct userdata{ int uid; std::string username; } Do I need to create a copy ctor or anything to return it from a function or to use it inside a STL container? Consider this function: userdata SomeClass::GetUserData(unsigned int uid) { //do error che...