Re: [Libevent-users] evdns C++ incompatibility

2007-11-06 Thread Nick Mathewson
On Tue, Oct 02, 2007 at 02:49:28AM -0400, Roger Clark wrote:
 At least on my system, gcc complains about 'class' being used in these
 places in evdns.h:

Hi, Roger!  I've checked in a possible fix for this as subversion
revision r486.  The fix will appear in the first 1.4 release, assuming
that it doesn't break anything else too badly.

For backward compatibility with existing C code, evdns_server_question
is now defined as:

struct evdns_server_question {
   int type;
#ifdef __cplusplus
   int dns_question_class;
#else
/* You should refer to this field as dns_question_class.  The
* name class works in C for backward compatibility, and will be
* removed in a future version. (1.5 or later). */
int class;
#define dns_question_class class
#endif
char name[1];
};

This should resolve bug 1826516 on the tracker.  Please let us know if
there are any remaining C++ issues with the header, or if you run into
anything else like this?

many thanks,
-- 
Nick Mathewson


pgp6lTrpfiTim.pgp
Description: PGP signature
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


Re: [Libevent-users] evdns C++ incompatibility

2007-10-02 Thread Nick Mathewson
On Tue, Oct 02, 2007 at 03:18:15PM -0400, Roger Clark wrote:
 Most of the header is already surrounded with extern C, but not the
 offending part. Just wanted to give someone a heads up.

I just changed it, but it doesn't do any good.  My understanding is
that 'extern C' is only for linkage, and it doesn't keep the
compiler from interpreting class as a C++ keyword.

For example, the following C++ is invalid:
   extern C {
 struct s { int class; };
   }

So, it looks like we've got a few options here:
  1) Rename the field and break old code that uses it.  I think I may
 be the only user of this interface, so this wouldn't necessarily
 be a tragedy... but if there are others, we might cause them some
 grief.

  2) Do some malarkey like

struct evdns_server_request {
   /* ... */
#ifdef __cplusplus
int dns_question_class;
#else
int class;
#define dns_question_class class
#endif
  /* ... */
};

 so that we don't break existing C code that uses the field, but
 we start building under C++, and everybody can start migrating to
 the question_class field name.

  3) Do something like

struct evdns_server_request {
   /* ... */
#ifdef __cplusplus
int dns_question_class;
#else
int class;
#endif
  /* ... */
};
 so that we break absolutely no old code, and C++ starts working.
 Of course, this would give the field a different name in C than
 in C++, and that's not so great.

yrs,
-- 
Nick Mathewson


pgpVc3QaMJg7s.pgp
Description: PGP signature
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users