c++

how can I get a std::set of keys to a std::map

I was writing an algorithm this morning and I ran into a curious situation. I have two std::maps. I want to perform a set intersection on the sets of the keys of each (to find which keys are common to both maps). At some point in the future, I think it's likely I'll also want to perform set subtraction here as well. Luckily, the STL ...

What am I missing from my environment variables for my linker to fail with LNK1181?

I have a Qt project which I have had a debug console displayed whilst I am developing, I am about to ship the product to I removed the qmake console command: CONFIG += console However when I do that I get the following error: link /LIBPATH:"c:\Qt\4.5.0\lib" /NOLOGO /INCREMENTAL:NO /LTCG /MANIFEST /MANIFESTFILE:"./_obj/win32\Lynx.interm...

VC++ Resource Files and Lengthy String Resources

In our app we have resource strings that are apparently too long for the compiler. The build breaks stating the "line length is too long." I have found little information about the topic of lengthy string resources and even had a difficult time finding what the limit on such a resource string is. Eventually I found this article which gi...

What's the difference between these two classes?

Below, I'm not declaring my_ints as a pointer. I don't know where the memory will be allocated. Please educate me here! #include <iostream> #include <vector> class FieldStorage { private: std::vector<int> my_ints; public: FieldStorage() { my_ints.push_back(1); my_ints.push_back(2); } void displayAl...

How can you find out the maximum size of the memory stack for a C++ program on linux? (gnu compiler)

I am curious about how to find out what the maximum stack size is for a particular compiler/os combo. I am using Ubuntu/GNU compiler. A few questions I have in addition are: Who controls the default maximum stack size; OS or compiler? Is the default maximum scaled according to total memory? (ie a machine with 2gb memory would have larg...

Adding OCX Control to a Resource Dialog (how Do I control it)

Hi there, I'm adding an OCX to a resource dialog that I've created in my C++ project. The ocx adds properly; but my question is how do I access the ocx programatically? I don't see a member variable (or even a class) attached to it. This is my .rc contents ////////////////////////////////////////////////////////////////////////////...

Negative Speedup on Multithreading my Program

On my laptop with Intel Pentium dual-core processor T2370 (Acer Extensa) I ran a simple multithreading speedup test. I am using Linux. The code is pasted below. While I was expecting a speedup of 2-3 times, I was surprised to see a slowdown by a factor of 2. I tried the same with gcc optimization levels -O0 ... -O3, but everytime I got t...

Calling Member Functions within Main C++

#include <iostream> using namespace std; class MyClass { public: void printInformation(); }; void MyClass::printInformation() { return; } int main() { MyClass::printInformation(); fgetc( stdin ); return(0); } /* How would I call the printInformation function within mainline? The error tells me that i need ...

Restrict functionality to a certain computer.

Hi, I have a program that is using a configuration file. I would like to tie the configuration file to the PC, so copying the file on another PC with the same configuration won't work. I know that Windows Activation Mecanism is monitoring hardware to detect changes and that it can tolerates some minor changes to the hardware. Is the...

how to open bpr projects in Borland Codegear C++ Buider 2009 ?

I'm trying to import the log4cpp project into Borland Codegear C++ Builder 2009 . The rar file of the project contains a bpr file which corresponds to a project. When trying to open it, an error popup window is shown, saying: OLE error 80131040, ClassID: {F8FEDD39-E3CE-4B8D-A657-9CA24686881F} I do not have idea of what's going on, an...

Is there a GCC preprocessor directive to check if the code is being compiled on a 64 bit machine ?

I am trying to do something like the following; #ifdef 64-bit #define DECIMAL_FORMAT %ld #else #define DECIMAL_FORMAT %d #endif . intptr_t d; . printf(“Some message with DECIMAL_FORMAT in the middle of it\n”, d); The variable 'd' being of the type 'intptr_t' needs '%d' format specifier on 32 bit machines and format specifier...

Interop sending string from C# to C++

I want to send a string from C# to a function in a native C++ DLL. Here is my code: The C# side: [DllImport(@"Native3DHandler.dll", EntryPoint = "#22", CharSet = CharSet.Unicode)] private static extern void func1(byte[] path); public void func2(string path) { ASCIIEncoding encoding = new ASCIIEncoding(); byte[] arr = encodi...

How to validate LPVOID to <Bad Ptr>

I'm working with C++ unmanaged, the problem that I have happens when I call a method that returns an LPVOID. LPVOID MyMethod(...); The problem is that this method sometimes returns a Bad Ptr and I want to know if there is a way of detecting this, if the value returned is a Bad Ptr. I have tried asking if it is NULL with no luck. The...

Is this extern harmless

main.h extern int array[100]; main.c #include "test.h" int array[100] = {0}; int main(void) { /* do_stuff_with_array */ } In the main.c module, the array is defined, and declared. Does the act of also having the extern statement included in the module, cause any problems? I have always visualized the extern statement as...

AMF0 parser in ObjectiveC

Hello guys, I am writing an application which connects to an FLV stream and parse data to extract SCRIPTDATAOBJECT. I successfuly get content of a DATASCRIPTOBJECT and am trying to parse AMF0 data to get some metadata, do you know sample code of AMF0 parsing ? Thanks a lot. Thierry ...

Differentiate Between Pointer and Reference at Run Time ANSI C++

How does one differentiate between pointers and references at runtime? For example, if I wanted to free a pointer of a data type without knowing whether it were a pointer or not how would I do so? Is there any method to tell if a variable has been allocated on the stack or through malloc()? void destInt(int* var) { free(var); } int...

Int Array Length C++

Hi guys. I have to use a dynamic length int array in my program, and want to be able to get the number of objects in it at various points in my code. I am not that familiar with C++, but here is what I have. Why is it not giving me the right length? Thanks. <#include <iostream> Using Namespace std; int length(int*); void main() { in...

What's wrong with my file dependencies?

I have a program using 3 header files and 3 .cpp files in addition to main.cpp. I'm using VC++ 2008. Here's the setup. All three headers are guarded with #ifndef HEADERNAME_H, etc. Also all three headers have corresponding .cpp files, which #include their respective headers. /* main.cpp */ #include "mainHeader.h" /* mainHeader.h *...

How to make a single line systabcontrol32 that scrolls but doesn't show a scrollbar

Hi I'm creating a systabcontrol32 control with the TCS_SINGLELINE style when I resize my window so the tab won't fit an up-down control appears that should allow me to scroll so I can see all the tabs. The thing is that the up-down buttons don't seem to work unless I add a the WS_HSCROLL property to the tab control witch makes it ugly ...

The precision of the long double output is not correct. What might be wrong?

I have a long double constant that I am setting either as const or not-const. It is longer (40 digits) than the precision of a long double on my test workstation (19 digits). When I print it out, it no longer is displayed at 19 digits of precision, but at 16. Here is the code I am testing: #include <iostream> #include <iomanip> #incl...