c++

How to run debug file on another computer?

I have a debug .exe file that i want to run on other machines that don't have MS Visual Studio 2008 installed on them. How can this be done? The release option doesn't work as the application does not function correctly when build in release (not sure why). At the moment I'm getting a message saying "This application has failed to start...

A few questions about foreach loop and performance

Hi! I have a few foreach related questions below I hope that somebody could answer. I know that most people do not care about the possibly insignificant differences, but I want to understand them for completeness. 1) Could somebody explain how the foreach keyword in Qt actually works behind the scenes. I would like to know if foreach cr...

Return an array of a known size in C++?

If I can pass in an array of a known size: void fn(int(*intArray)[4]) { (*intArray)[0] = 7; } why can't I return one: int intArray[4] = {0}; int(*)[4] fn() { return &intArray; } here, the ")" in "(*)" generates "syntax error : )". ...

gcc options for fastest code

I'm distributing a C++ program with a makefile for the Unix version, and I'm wondering what compiler options I should use to get the fastest possible code (it falls into the category of programs that can use all the computing power they can get and still come back for more), given that I don't know in advance what hardware, operating sys...

Getting value of LSB from Hex (C code)

Hi - first post here :) I've got a code like this in C: unsigned char const data[ ] = {0x0a, 0x1d, 0xf0, 0x07}; I need to extract it such that the final value is: 0xa1df7 I have only been able to extract and get it working if the hex values that have at least 1 zero: unsigned char const data[ ] = {0x0a, 0xd0, 0xf0, 0x07}; using...

ld returned 1 exit status

This is the code that i'm trying to run: #include <QApplication> #include <QPushButton> int main(int argc,char *argv[]) { QApplication app(argc,argv); return app.exec(); } And this is the error that i'm getting: :-1: error: collect2: ld returned 1 exit status ...

Data Structures using C or C++?

What are the advantages of using C++ based Classes/Objects over using legacy C Structures for managing standard Data Structures like Linked List, Stack, Tree, Queue ..etc? Let me know if the question is not clear. ...

Resources in static library question

Hello! This isn't a duplicate of http://stackoverflow.com/questions/531502/vc-resources-in-a-static-library because it didn't help :) I have a static library with TWO .rc files in it's project. When I build my project using the Debug configuration, I retrieve the following error (MSVS2008): fatal error LNK1241: resource file res_yyy.r...

get a text from the error code returns from the GetLastError() function

Hi, I need to get the text of an error code that i got from the GetLastError function. I saw a few examples but i want a function that get the code and return the string. Thank's you all ...

What time function do I need to use with pthread_cond_timedwait?

The pthread_cond_timedwait function needs an absolute time in a time timespec structure. What time function I'm suppose to use to obtain the absolute time. I saw a lot of example on the web and I found almost all time function used. (ftime, clock, gettimeofday, clock_gettime (with all possible CLOCK_...). The pthread_cond_timedwait use...

MySql Driver not loaded

I use Visual Studio 2008, MySQL 5.0.90,Qt 4.6.3 and C++ I try connect MySql but it gives this error messages. Driver not loaded. I am new programmer. How cann I solve this problem? Thank a lot. ...

Implementing operator< in C++

I have a class with a few numeric fields such as: class Class1 { int a; int b; int c; public: // constructor and so on... bool operator<(const Class1& other) const; }; I need to use objects of this class as a key in an std::map. I therefore implement operator<. What is the simplest implementation of operator< to us...

Is there an online name demangler for C++?

I'm getting a fairly long and confusing link error, and would love it if I could just paste it into some textbox on some website and have the names un-mangled for me. Does anyone know of such a service? ...

IOCTL_MOUNTMGR_QUERY_POINTS

Dear all, when i include #include to use the IOCTL_MOUNTMGR_QUERY_POINTS i get the below error fatal error C1083: Cannot open include file: Mountmgr.h: No such file or directory How can i solve this error. Please guide me ...

Expected class name before ',' or ';'

Hi All, I am getting an "Expected class-name before , or ; and I dont quite get how to fix it. Here is where the error is: class FXHost : public CPLAT::CP_Application, public CPLAT::CP_M_Listener { The file is FXHost.h and CPLAT:: is obviously a namespace where CP_Application and CP_M_Listener are. I dont see why this would be w...

keyboard layout direction

hi, I would like to detect the direction of the current typing (input) language. I may detect the language by means of "GetKeyboardLayout", but then I'll have to check if it equals to Arabic or Hebrew and so on, is there any way just to detect the direction, i.e. left to right or right to left. thanks! mike. ...

How to use the vtable to determine class type

I was recently on an interview for a position where C/C++ is the primary language and during one question I was told that it's possible to use the vtable to determine which class in a hierarchy a base pointer actually stores. So if, for example you have class A { public: A() {} virtual ~A() {} virtua...

What is your technology stack for developing in C++?

What is your technology stack for developing C++ applications? I'm trying to decide on one. So far this is what I have in my list: Boost Boost::Unit Testing googlemock log4cpp doxygen ant hg ...

Most efficient way to map one fileID to another

I am in the process of localizing a game. I have roughly 1% of the game assets (around 200 of 20k files) that need to be replaced per language with different assets, 1 to 1. I am mulling over the 'best' way to do this in a very RAM starved envirnoment. Here's my current list of ideas: Hash off the file IDs to convert at nearly const...

Is it safe to read global data from multiple threads?

The scenario is as follows: Create an instance of a class (std::map) and sore it as global variable. Spawn threads. Threads read and use the same global instance of the class (call methods, access members etc) All spawned threads quit Global class instance is destroyed No mutex used, no spawn thread modifies the global class instance...