Subject: Calling c-client from C++ code

From: Romain Vignes <[email-masked]>
Date: Wed, 18 Aug 1999 15:20:56 +0200

Hello,

I am in the process of writing a C++ program that needs to fetch
messages from POP3/IMAP servers.

I have encountered some problems when including the "mail.h" file from a
C++ code. In fact this include file contains some C++ keywords that are
used as struct/field names. The used keywords are "private" and
"function".

The C++ compiler breaks with some obscur error messages.

I have tried to frame the file inclusion with an extern "C" block :

extern "C"
{
#include "mail.h"
}

But it does not change anything.

Is there a way to solve (or bypass) this problem ? I would like to known
if somebody has successfully compiled the c-client toolkit in a C++
environment.

BTW, I am using GCC 2.7.2 on a SCO UNIX 3.2v4 system.

Thanks in advance !

--
Romain Vignes
France Multimédia
<mailto:[email-masked]>

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Karsten Ballueder <[email-masked]>
Date: Wed, 18 Aug 1999 14:40:06 +0100 (BST)

> if somebody has successfully compiled the c-client toolkit in a C++

Look at the mahogany source code
http://mahogany.home.dhs.org/ we have patchec c-client to
compile cleanly in a C++ environment. Mainly involved
renaming illegal variable names such as "private".

--
 Karsten Ballüder  http://Ballueder.home.dhs.org/  mailto:[email-masked]
 Physics Department, Heriot-Watt University, Edinburgh, EH14 4AS, Scotland
                     Tel. +44-(0)-131-4513068  Fax. +44-(0)-131-4513136
            "In a world without fences, who needs Gates?"

---

From: "Alex Shvedov" <[email-masked]>
Date: Wed, 18 Aug 1999 10:29:21 -0400

No, Karsten, I don't see anything suspicious in the header.

Our mail server runs under Linux, I use MS Outlook Express 5.0
under WinNT.

See for yourself:

([email-masked] [140.142.56.1]) by
ares.voicerite.com (8.8.3/8.8.3) with ESMTP id IAA23594 for
<[email-masked]>; Wed, 18 Aug 1999 08:33:31 -0400
Received: from host ([email-masked]
[140.142.56.13])
 by lists2.u.washington.edu (8.9.3+UW99.02/8.9.3+UW99.01) with
SMTP id GAA05059;
 Wed, 18 Aug 1999 06:41:50 -0700
Received: from mxu2.u.washington.edu (mxu2.u.washington.edu
[140.142.32.9])
 by lists.u.washington.edu (8.9.3+UW99.02/8.9.3+UW99.01) with
ESMTP id GAA31272
 for <[email-masked]>; Wed, 18 Aug 1999
06:41:37 -0700
Received: from phy.hw.ac.uk (innpin.phy.hw.ac.uk [137.195.28.2])
 by mxu2.u.washington.edu (8.9.3+UW99.02/8.9.3+UW99.06) with
ESMTP id GAA10824
 for <[email-masked]>; Wed, 18 Aug 1999 06:41:21 -0700
Date: Wed, 18 Aug 1999 14:40:06 +0100 (BST)
Reply-To: [email-masked]
Sender: [email-masked]
<mailto:[email-masked]?body=unsubscribe%20c-client>
List-Subscribe:
<mailto:[email-masked]?body=subscribe%20c-client%20You
rName>
List-Owner: <mailto:[email-masked]> (Human
contact for the list)
List-Post: <mailto:[email-masked]>
From: Karsten Ballueder <[email-masked]>
To: [email-masked], [email-masked]
Subject: Re: Calling c-client from C++ code
In-Reply-To: <[email-masked]>
References: <[email-masked]>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Disposition: INLINE
X-Face:
&dD[PF]+xd[=UM/+Kck=s[Toj/_GKiL&}*"uCT]>saEa5@Ux-P?vpT~<zo>1[<'A`
Kh~C0V

/Q>kj)>t]rT9g`ez2rkK3y[\,>2*A^9BRDuD!y3e~Kw%_-a)T&OfLn<,W?qQ!$Hue
;?ZF>hQI9~R=C
 d|PGg<VG".tBm&da|R`{c~xu)W/=:\3vdQ)WH&Kt=:
X-Listprocessor-Version: 8.1 -- ListProcessor(tm) by CREN

etc.

---

From: Romain Vignes <[email-masked]>
Date: Thu, 26 Aug 1999 17:46:51 +0200

> renaming illegal variable names such as "private".

Great. It works for me too.

I do not know if the official developper(s) and maintainer(s) of the client
is(are) listening to this thread, but I think it could be a great enhancement to
incorporate these patches in the official package. All the c-client developper
community will benefit from such a thing.

If needed, I can make my patches available.

---

From: Mark Crispin <[email-masked]>
Date: Thu, 26 Aug 1999 10:08:04 -0700 (PDT)

> community will benefit from such a thing.

The problem is that this is never-ending.  There have been already been
several episodes in the past where I was asked to change lots of files
because I inadvertantly used variables with names such as "new".  
"private" is just the latest, and there are documentation reasons why I
wish to use that name; it's to indictate components that are private to
c-client and the application is not to touch.

These names are perfectly valid names in C.  No C specification reserves
these names.  Even if I gave in (again) this time, there's no guarantee
that it won't happen again.  It's certain to happen again.

It's not all that difficult to work around this without patches.  Just do
something like:
#define private c_client_private
#include <mail.h>
#undef private

If you're trying to compile c-client with a C++ compiler instead of a C
compiler, I don't know what to tell you.  c-client is written in C, not
C++.  I don't promise that a Fortran compiler will compile c-client
either.  I suggest compiling c-client with a C compiler, and link your C++
binaries with the resulting binaries from the C compiler.

If you insist upon using a different programming language (and C++ *is* a
different and incompatible programming language otherwise we wouldn't be
having this discussion), take a look to see if your C++ compiler has a
flag to make it compatible with C, and use that flag.

-- Mark --

* RCW 19.190 notice: This email address is located in Washington State.	*
* Unsolicited commercial email may be billed $500 per message.		*
Science does not emerge from voting, party politics, or public debate.

---

From: Romain Vignes <[email-masked]>
Date: Fri, 27 Aug 1999 17:24:16 +0200

> c-client and the application is not to touch.

I do not think so. The set of C++ reserved keyword is not infinite. It can be found
inside any good book on the C++ programming language. It is not very difficult to
keep an eye on this keyword set when adding new type definitions in the c-client
include files.

Recent source code editors can manage keywords set and display them with custom
colors. I am currently using Metrowerks CodeWarrior and the C++ keywords are
automatically displayed in blue. Cool !!

> #define private c_client_private

No, it does not work.
The "function" keyword is also used in "mail.h" and this keyword can not be redefined
at the pre-processor level.

> flag to make it compatible with C, and use that flag.

This is absolutely not what I want to do. I agree that c-client uses the C language
and must be compiled with a C compiler.

But today the majority of C-API's are C++ compatible. Why not c-client ??