c++

What does "error: invalid function declaration" mean?

With GCC 4.1.2, I get the error tmp.cpp:8: error: invalid function declaration for the following code namespace edit { class A { public: void foo( ); }; } void edit:A::foo( ) { } ...

Why allow concatenation of string literals?

I recently got bit by a subtle bug. char ** int2str = { "zero", // 0 "one", // 1 "two" // 2 "three",// 3 nullptr }; assert( values[1] == "one"_s ); // passes assert( values[2] == "two"_s ); // fails If you have godlike code review powers you'll notice I forgot the , after "two". After the considerable effort to fin...

Is it safe to define _HAS_TRADITIONAL_STL to enable STL functionality ?

In attempting to use std::select1st from <functional> in a VS2008 project I found that it was ifdef'd out by a _HAS_TRADITIONAL_STL guard. Is there a reason for this? Is it safe to simply define _HAS_TRADITIONAL_STL before including <functional>? ...

Channel Audio from .mp4?

Hi there. I am at a loss here after searching around with no results. I am attempting to channel the audio specifically from an .mp4 for use in a driver. I am aware that there are programs which extract the audio from .mp4's, but I am looking for another approach without using external applications such as those.. is there any directi...

How to launch a mac application without a terminal window.

I've written an open-source c++ application and it works fine on Windows and Linux, I finally got a Mac Mini (with 10.5.8) so I've just been testing the Mac version. My application works fine when running it from inside a terminal window and typing ./appname , but if instead I double click on it from the finder, then it opens a termnial...

Why does a multilanguage solution not work?

My solution has a C# application project C# User Controls project C++ Mathematics project One of the UserControls uses function from the Mathematics (C++ project). This UserControl is used in the application. Building and starting the application works just fine. When typing the IntelliSense suggests all the contained classes and me...

Use WPF DLL Assembly in ASP.NET problem

Hello, I have C++ project that compiles as DLL Assembly in .NET 3.5 SP1 Project is used for Image rendering processing by using WPF (it loads 2 images from local folder, applies one image on another and saves the output file in the same folder). I want to use that that project as a reference in ASP.NET project to the rendering on the web...

How to parse a tar file in C++

What I want to do is download a .tar file with multiple directories with 2 files each. The problem is I can't find a way to read the tar file without actually extracting the files (using tar). The perfect solution would be something like: #include <easytar> Tarfile tar("somefile.tar"); std::string currentFile, currentFileName; for(int...

Error LNK1223 on ARM builds

eMbedded Visual C++ 3 project, building for PocketPC 2000. On the ARM build, the linker throws the following error: fatal error LNK1223: invalid or corrupt file: file contains invalid pdata contributions On SH3, the project compiles, links, and works. The project also works when built for ARM on Visual C++ 2005, but I need to test buil...

Usage of std::string.append causes "Stack around the variable 'result' was corrupted"

I have the following code : std::string Utils::get() { std::string result; result.append(1, 'x'); result.append(1, 'x'); result.append(1, 'x'); return result; } I expect 'xxx' to be returned. However, when I run under debug mode, I get the warning "Stack around the variable 'result' was corrupted" Am I using app...

Manage bad_alloc exception in C++ construtor

I have Java experience and recently am doing some C++ coding. My question is that if I have class A, in which I have to instantiate class B and class C as two of the member variables of A. If in the constructor of A, should I assume that allocations of class B and C never fail, and handle the bad allocation exception in the destructor o...

Simple constructor with initializer list?

Below I've included my h file, and my problem is that the compiler is not liking my simple exception class's constructor's with initializer lists. It also is saying that string is undeclared identifier, even though I have #include <string> at the top of the h file. Do you see something I am doing wrong? For further explanation, this is o...

Calling class method through NULL class pointer

I have following code snippet: class ABC{ public: int a; void print(){cout<<"hello"<<endl;} }; int main(){ ABC *ptr = NULL: ptr->print(); return 0; } It runs successfully. Can someone explain it? ...

Compiler error: memset was not declared in this scope

Hi, I am trying to compile my c program in ubuntu 9.10 (gcc 4.4.1). I am getting this error: Rect.cpp:344: error: ‘memset’ was not declared in this scope But the problem is I have already included in my cpp file: #include <stdio.h> #include <stdlib.h> And the same program compiles fine under ubuntu 8.04 gcc 4.2.4). Please tell m...

classes and static variables in shared libraries

I am trying to write something in c++ with an architecture like: App --> Core (.so) <-- Plugins (.so's) for linux, mac and windows. The Core is implicitly linked to App and Plugins are explicitly linked with dlopen/LoadLibrary to App. The problem I have: static variables in Core are duplicated at run-time -- Plugins and App have diff...

creating child process

Write a program to creates two childs by using send –pipe and receive –pipe primitives.Each child Process reads from a different serial line and sends the character read back to parent process through a pie. The parent process outputs all characters received. A child terminates when exclamation point character is received.The parent proc...

Customizing compare in bsearch()

I have an array of addresses that point to integers ( these integers are sorted in ascending order). They have duplicate values. Ex: 1, 2, 2, 3, 3, 3, 3, 4, 4...... I am trying to get hold of all the values that are greater than a certain value(key). Currently trying to implement it using binary search algo - void *bsearch( const vo...

GCC exports decorated function name only from dll

Hi Guys, I have a dll, it exports a function... extern "C" int __stdcall MP_GetFactory( gmpi::IMpUnknown** returnInterface ) { } I compile this with Code::Blocks GCC compiler (V3.4.5). Problem: resulting dll exports decorated function name... MP_GetFactory@4 This fails to load, should be plain old... MP_GetFactory I've researche...

Memory leak in C++ program.

Thanks guys, for every const char * i went ahead and replaced it with string. THanks again! Could someone help please? :/ (This is not a homework question) #include <iostream> #include <string> #include <vld.h> using namespace std; class Time { private: string dayTime; int hour, minute; public: Time(int hour, ...

Trying to load a DLL with LoadLibrary and get R6034 "An application has made an attempt to load the C runtime library incorrectly"

I'm writing a wrapper program that loads Winamp input plugins. I've got it working well so far with quite a few plugins, but for some others, I get an error message at runtime when I attempt to call LoadLibrary on the plugin's DLL. (It seems to happen mostly with plugins that were included with Winamp.) A dialog appears and gives me t...