From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: Xen tools (libxs, xenstore) and C++ Date: Tue, 22 Jan 2013 15:26:20 +0000 Message-ID: <50FEAF9C.609@citrix.com> References: <50FEAD68.1000604@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <50FEAD68.1000604@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Razvan Cojocaru Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 22/01/13 15:16, Razvan Cojocaru wrote: > Hello, > > I'd like to use xenctrl.h and a handful of other headers in a C++ = > application. The headers I'm interested now are xenctrl.h, = > xen/hvm/save.h, xen/mem_event.h and xenstore.h. Unfortunately, they're = > not C++-friendly. > > Here's why: > > 1. None of the headers enclose their contents in: > > #ifdef __cplusplus > extern "C" { > #endif > > /* contents here */ > > #ifdef __cplusplus > } > #endif > > 2. xen/arch-x86/hvm/save.h uses the C++ keyword 'new' as a parameter = > name (quite a few times). > > 3. C++ (being type-safer) frowns upon such assignments as: > > struct hvm_hw_cpu *newcpu=3Dh; // h is void* > > which should be explicitly written as: > > struct hvm_hw_cpu *newcpu=3D(struct hvm_hw_cpu *)h; > > 4. xenctrl.h typedefs "enum xc_error_code xc_error_code;" _before_ "enum = > xc_error_code { /* ... */ }" has been defined, which C++ doesn't allow. > > I'm also getting: > > /usr/include/xen/mem_event.h:71:1: error: expected =91;=92 after union = > definition > /usr/include/xen/mem_event.h:71:1: error: expected =91:=92 before =91;=92= token > > where the DEFINE_RING_TYPES(mem_event, mem_event_request_t, = > mem_event_response_t); macro is being expanded in mem_event.h. > > Are there plans to have the userspace libraries be friendlier to C++? Patches welcome :) I think C++ friendliness is a good idea (especially as I think I might be needing C++ friendliness at some point in the not-too-distant future) ~Andrew > > Thanks, > Razvan Cojocaru > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel