c++

Joining keys/values from C++ STL associative containers

I have a join function that operates on STL strings. I want to be able to apply it to to a container like this: getFoos(const std::multimap<std::string, std::string>& map) { return join_values(",", map.equal_range("foo")); In other words, find all matching keys in the collection and concatenate the values into a single string wit...

How to increase the gcc executable stack size?

I have large Boost/Spirit metaprogram that is blowing gcc's stack when I try to compile it. How can I increase gcc's stack size, so I can compile this program? Note: There's no infinite recursion going on, but there is enough incidental recursion to exhaust gcc's stack. ...

Where should I look to solve a symbol lookup/undefined symbol with an automake/autoconf project?

In one project, I have two noinst_PROGRAM's defined. One of them works just fine, but the other is giving me the following message: /home/altern8/workspaces/4355/libgdata/test/.libs/lt-gdatacalendar: symbol lookup error: /home/altern8/workspaces/4355/libgdata/test/.libs/lt-gdatacalendar: undefined symbol: _ZN5gdata7service7Se...

How can I get a block of memory from a function and write it to a file?

I want to write the data "somebytes" that I get from a function called NextUnit() to a file named "output.txt", but the code that I wrote does not work. When I open the file, it does not look like my "somebytes". Here is the code: #include <stdio.h> #include <string.h> char* NextUnit() { char Unit[256]; strcpy(Unit,"somebytes")...

Enter File Name When Executing Program In C++

Hello, I'm learning C++, then i was searching for some codes for learn something in the area that i love: File I/O, but i want to know how i can tweak my code for the user type the file that he wants to see, like in wget, but with my program like this: C:\> FileSize test.txt The code of my program is here: // obtaining file size #in...

Developing Math libraries

I am looking to create a custom math library for the project I am working on. The project is written in C#, and I am slightly concerned whether C# will be fast enough. The library will have a number of custom math formulas and equasions to be applied to very large data sets. Simulations and matrix operations will be done as well (i.e. Mo...

Is this a good practice? "/*/something/*/something//*/"

/*/ comment here do some thing. /*/ do some thing. //*/ Why people write code like that? Is this a good practice? ...

Qt: Add UI Elements using Qt Script

Is it possible to add new GUI elements into a Qt program using QtScript? For instance assuming the variable "layout" is a vertical layout would this be acceptable? var label = new QLabel("Text"); layout.addWidget(label); ...

How to check the class id is registered or not?

Hi i am checking the GUID of SqlClass which is in my Test.dll But it does not give success it failed with value... Whatis wrong in this code. #include <windows.h> #include <iostream> using namespace std; int main() { HKEY hk; long n = RegOpenKeyEx(HKEY_CLASSES_ROOT,TEXT("\\CLSID\\SqlClass"), 0,KEY_QUERY_VALUE, &...

c++ exception handling

After going through some links on exception handling (1, 2, and 3), I know that C++ programs can throw pretty much anything as exceptions (int, char*, string, exception class). I know that std::exception is the base class for standard exceptions thrown by the program. However, I'm trying to design a try...catch block as such: try { ...

Finding the nearest used index before a specified index in an array (Fast)

This question is related to http://stackoverflow.com/questions/1053242/array-of-pairs-of-3-bit-elements This array has 52 pairs (about 40 bytes), and I want to find the first pair before the specified one that has it's values different from 0 (used pair). The obvious solution would be to check each pair < than this one (scan from right t...

Windows Setup Project without .net dependency

I have made a custom dll for my setup project. My dll is very simple, registering few services, not CLR or any 3rd party lib dependent. Have statically linked with msi.lib only. I have removed the .net and windows installer prerequisite requirements from the setup project. My setup fails on macines not having .net framework..? As I hav...

Echo off problem in console application (Linux)

Hello, I am facing a strange problem in my console application. First of all, the code snippet: main.cpp #include "DebugInterface.h" static sigset_t signalSet; static pthread_t CleanupHandlerThread; DebugInterface* debugInterface = NULL; void* CleanupHandler (void* param) { int32_t sig, err; err = sigwait (&signalSet, &sig)...

temporary object, function parameters and implicit cast

In the following scenario: struct Foo { // ... operator Bar() {... } // implicit cast to Bar } Foo GetFoo() { ... } void CallMeBar(Bar x) { ... } // ... CallMeBar( GetFoo() ); [edit] fixed the cast operator, d'oh[/edit] GetFoo returns a temporary object of Type Foo. Does this object survive until after CallMe returns? What d...

How to recreate style used by resource editor when creating MFC controls dynamically?

I need to create some controls in a MFC dialog dynamically. The creation works fine so far, but the controls created dynamically are looking different from controls created with the resource editor. Some controls even behave different. I think, that I'm missing some initializations the generated code does. Currently I only create CStati...

How to add 50-digit numbers in C++?

In C++ I want to add two 50-digit numbers. I use an array to keep each. It means that I want to add two arrays. My problem is that I want to do this in a function named AddNum() and pass the result to another function named WriteNum for printing and I don't know how to pass an array returned by one function to another function. hope that...

Getting the number of logged on users in Windows

Hello! Let's say I have 3 logged on users. I have a test application which I use to enumerate the WTS sessions on the local computer, using WTSEnumerateSessions. After that, I display the information contained in each of the returned WTS_SESSION_INFO structure. On Windows XP, there are 3 structures displayed: Session 0, 1, and 3 (for e...

Portable Compare And Swap (atomic operations) C/C++ library?

Is there any small library, that wrapps various processors' CAS-like operations into macros or functions, that are portable across multiple compilers? PS. The atomic.hpp library is inside boost::interprocess::detail namespace. The author refuses to make it a public, well maintained library. Lets reopen the question, and see if there ar...

Binding to a member variable

Hi, I am confused as to what boost::bind does when we bind to member variables. With binding to member function, we essentially create a function object, and then call it passing to it the arguments that are provided or delayed and substituted via placeholders. But what does this expression do behind the scenes: boost::bind(&std::pair...

How to handle incorrect values in a constructor?

Please note that this is asking a question about constructors, not about classes which handle time. Suppose I have a class like this: class Time { protected: unsigned int m_hour; unsigned int m_minute; unsigned int m_second; public: Time(unsigned int hour, unsigned int minute, unsigned int second); }; While I would wa...