Skip site navigation (1)Skip section navigation (2)
Date:      07 Jul 2000 16:39:05 +0200
From:      Rasmus Kaj <kaj@raditex.se>
To:        "Jim King" <king@sstar.com>
Cc:        Rasmus Kaj <kaj@raditex.se>
Subject:   Re: Any chance of changing struct member names in nameser.h?
Message-ID:  <847layqa2e.fsf@frodo.sickla.raditex.se>
In-Reply-To: "Jim King"'s message of "Fri, 7 Jul 2000 09:19:10 -0500"
References:  <200007071320.JAA86645@lakes.dignus.com> <003d01bfe81e$553eb8a0$a44b8486@jking>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>> "JK" == Jim King <king@sstar.com> writes:

 >> > > extern "C" {
 >> > > #include <header_with_cpp_bogons.h>
 >> > > }

 JK> You're right, my bad.  Son of a gun, I've used 'extern "C"' for gobs of
 JK> stuff but I guess I never ran into C header files that had C++ reserved
 JK> words.

 JK> In that case, although it's considerably more work I'd take a look at
 JK> writing some C wrappers around the offending stuff.  You could write the
 JK> wrappers such that they'd compile with the offending include file, and be
 JK> callable from C++.  Sounds tedious and time consuming, but it might be
 JK> quicker than waiting for someone to fix the headers in question.

Here's something that *might* work:

extern "C" { // For function definitions
#define class c_class
#include <bad_header.h>
#undef class
}

After this, you just use the struct as usual, but call the class field 
c_class in your source. The name shouldn't matter, since it's just an
offset in the struct anyway ...

Of course, it woulde be better to have the bad header fixed, but as
Jim says, that probably will take some time ...

If the bad header uses any other words that is reserved in C++, they
can be handled in the same way ...

-- 
Rasmus Kaj -------------------- rasmus@kaj.se - http://Raditex.se/~kaj/
 \                             Pro is to con as progress is to Congress
  \------------------------------------------------- http://Raditex.se/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?847layqa2e.fsf>