All of lore.kernel.org
 help / color / mirror / Atom feed
* Xen tools (libxs, xenstore) and C++
@ 2013-01-22 15:16 Razvan Cojocaru
  2013-01-22 15:26 ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Razvan Cojocaru @ 2013-01-22 15:16 UTC (permalink / raw)
  To: xen-devel@lists.xen.org

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=h; // h is void*

which should be explicitly written as:

struct hvm_hw_cpu *newcpu=(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 ‘;’ after union 
definition
/usr/include/xen/mem_event.h:71:1: error: expected ‘:’ before ‘;’ 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++?

Thanks,
Razvan Cojocaru

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Xen tools (libxs, xenstore) and C++
  2013-01-22 15:16 Xen tools (libxs, xenstore) and C++ Razvan Cojocaru
@ 2013-01-22 15:26 ` Andrew Cooper
  2013-01-22 15:35   ` Razvan Cojocaru
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2013-01-22 15:26 UTC (permalink / raw)
  To: Razvan Cojocaru; +Cc: xen-devel@lists.xen.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=h; // h is void*
>
> which should be explicitly written as:
>
> struct hvm_hw_cpu *newcpu=(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 ‘;’ after union 
> definition
> /usr/include/xen/mem_event.h:71:1: error: expected ‘:’ before ‘;’ 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Xen tools (libxs, xenstore) and C++
  2013-01-22 15:26 ` Andrew Cooper
@ 2013-01-22 15:35   ` Razvan Cojocaru
  2013-01-22 15:36     ` Razvan Cojocaru
  0 siblings, 1 reply; 4+ messages in thread
From: Razvan Cojocaru @ 2013-01-22 15:35 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel@lists.xen.org

>> /usr/include/xen/mem_event.h:71:1: error: expected ‘;’ after union
>> definition
>> /usr/include/xen/mem_event.h:71:1: error: expected ‘:’ before ‘;’ token
>>
>> where the DEFINE_RING_TYPES(mem_event, mem_event_request_t,
>> mem_event_response_t); macro is being expanded in mem_event.h.

This one was cause because ring.h was using the C++ keyword 'private'.

> 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)

OK, hopefully I'll manage to patch these headers tomorrow (of course, 
there are others...).

Cheers,
Razvan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Xen tools (libxs, xenstore) and C++
  2013-01-22 15:35   ` Razvan Cojocaru
@ 2013-01-22 15:36     ` Razvan Cojocaru
  0 siblings, 0 replies; 4+ messages in thread
From: Razvan Cojocaru @ 2013-01-22 15:36 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel@lists.xen.org

> This one was cause because ring.h was using the C++ keyword 'private'.

'Caused by ring.h using...'. Sorry, had one of those days.

Thanks,
Razvan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-22 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22 15:16 Xen tools (libxs, xenstore) and C++ Razvan Cojocaru
2013-01-22 15:26 ` Andrew Cooper
2013-01-22 15:35   ` Razvan Cojocaru
2013-01-22 15:36     ` Razvan Cojocaru

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.