c++

Iterate Over Struct; Easily Display Struct Fields And Values In a RichEdit Box

Is there an easier way to display the struct fields and their corresponding values in RichEdit control? This is what I am doing now: AnsiString s; s = IntToStr(wfc.fontColor); RichEdit1->Lines->Append(s); etc... Is there an easier way than having to individually call each one? I want to read a binary file and then display the corre...

Does the stack get unwound when a SIGABRT occurs?

Hi, Does the stack get unwound (destructors run) when a SIGABRT occurs in C++? Thanks. ...

Where does the -DNDEBUG normally come from?

Hi, Our build system has somehow changed such that optimized builds are no longer getting the -DNDEBUG added to the compile line. I searched our makefiles and don't find this. So the question is, where does -DNDEBUG originate for most people and how might that have changed? Before we did have -DNDEBUG and I don't think this was remov...

OpenDDS and notification of publisher presence

Problem: How can I get liveliness notifications of booth publisher connect and disconnect? Background: I'm working with a OpenDDS implementation where I have a publisher and a subscriber of a data type (dt), using the same topic, located on separate computers. The reader on the subscriber side has overridden implementations of on_data_...

virtual functions in C++

In my C++ program: #include<iostream.h> class A { public: virtual void func() { cout<<"In A"<<endl; } }; class B:public A { public: void func() { cout<<"In B"<<endl; } }; class C:public B { public: void func() { cout<<"In C"<<endl; } }; int main() { B *p...

How to prevent a globally overridden "new" operator from being linked in from external library

In our iPhone XCode 3.2.1 project, we're linking in 2 external static C++ libraries, libBlue.a and libGreen.a. libBlue.a globally overrides the "new" operator for it's own memory management. However, when we build our project, libGreen.a winds up using libBlue's new operator, which results in a crash (presumably because libBlue.a is maki...

C++ text menu: writing, reading, and sorting data

Hey guys, So my assignment is to create multiple classes for a Person, Name, ID #, Address, and Phone #. Name makes up: First, Middle, and Last name. ID # makes up: 9 digits. Address makes up: street, city, state, and 5 digit zip code. Phone # makes up: 3 digit area code and 7 digit number. Person makes up: a full Name (First, Middle, L...

C++ how to destruct an array

#include <cstdlib> #include <iostream> using namespace std; const unsigned long MAX_SIZE = 20; typedef int ItemType; class Heap { private: ItemType array[MAX_SIZE]; int elements; //how many elements are in the heap public: Heap( ) ~Heap( ) bool IsEmpty( ) const bool IsFull( ) const Itemt...

windows: is it possible to dump (direct) a text file into a named pipe

I have a setup where a program gets its input like so: 1) user enters a command in a command prompt 2) the text from the command prompt is written to a named pipe 3) a process on the other side of the pipe is reading the input parse and execute the command I would like to have the ability to store a set of commands in a text file an...

How do I replace __asm jno no_oflow with an intristic in a VS2008 64bit build?

I have this code: __asm jno no_oflow overflow = 1; __asm no_oflow: It produces this nice warning: error C4235: nonstandard extension used : '__asm' keyword not supported on this architecture What would be an equivalent/acceptable replacement for this code to check the overflow of a subtraction operation that happened before it? ...

Template class method collides with overloaded method.

Hi, I have a template class in C++ (somewhat simplified): template<typename T> struct C { T member; void set(const &T x) { member = x; } void set(int x) { member = x; } }; As you can see the set() function can be called either with the type T, or with an int. This works fine unless T is an int, in which case I get an ambiguous c...

pure virtual functions

In the C++ program: #include<iostream.h> class A { public: virtual void func()=0; }; class B:public A { public: void show() { func(); ...

C++: duplicated static member?

I have a class which needs to be a singleton. It implemented using a static member pointer: class MySinglton { public: static MySinglton& instance() { ... } private: static MySinglton* m_inst; }; This class is compiled into a .lib which is used in multiple dlls in the same application. The problem is that each dll sees a diffe...

Socket Send error

Hi, I am using a unix socket. When buffer is send to the socket it gives me unknown error 196. Please help on this. BOOL SendData(int iBuffer) { //Send data over socket int nRet = send(m_listenSock, m_cBuffer, iBuffer, 0); if(SOCKET_ERROR > nRet) { //log the error char temp; int length= sizeof(int); ...

Good Windows Registry Wrapper for C++

Hi, Does anyone know of any good free/open source Windows Registry wrappers for VC++ which do not require MFC (i.e. can be run in a console app)? ...

Socket Send error as Broken Pipe

Hi, From A TCP client when i call the send to server. It is giving Broken Pipe error. ...

Calling a .NET function with variable number of parameters from unmanaged code

Hello, I would like to call C# function with variable number of parameters: void f1(object arg1, params object[] argsRest); from unmanaged, C function with variable parameters that wraps f1. How can this be achived? ...

Linker can not find static library in same directory

I'm porting some Visual Studio 2008/VC9 stuff to Code::Blocks/MinGW and for some reason the linker cannot find a static library from another project in the workspace. In Visual Studio 2008 I could just set the static lib project as a dependency, and it would build in the right order (i.e. static lib needs to be built before linking the ...

searching for winapi functions

Hi there, I'm learning programing windows applications with C++. Now I'm reading about messages and I'm playing with the spy++. What function spy++ use in order to mark/highlight the window under mouse cursor? Also, can you give me some tips about using MSDN? I'm my opinion is not user friendly at all. I'm learning programming by my...

CPP: avoiding macro expansion of a macro function parameter

what I'd like to do (for logging purposes) is something like this: this code has been written to show my problem, actual code is complex and yes, I have good reasons to use macros even on C++ =) # define LIB_SOME 1 # define LIB_OTHER 2 # define WHERE "at file #a, line #l, function #f: " // (look for syntax hightlighting error at SO x...