[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] RFC: Make xen's public headers a little friendlier for C++.



>>> On 26.02.15 at 14:11, <tim@xxxxxxx> wrote:
> Shuffle some struct definitions up to file scope so that they remain
> in scope in C++ when they're used again later.
> 
> Add an automatic check for similar C++ pitfalls, to be run only when
> g++ is available.
> 
> RFC because it's not clear whether we want to make any commitments to
> have the public headers be C++-friendly.

I like this, and it looks it was easier to do than I thought. Albeit ...

> --- a/xen/include/Makefile
> +++ b/xen/include/Makefile
> @@ -87,13 +87,19 @@ compat/xlat.h: $(addprefix compat/.xlat/,$(xlat-y)) 
> Makefile
>  
>  ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
>  
> -all: headers.chk
> +all: headers.chk headers++.chk
>  
> -headers.chk: $(filter-out public/arch-% public/%ctl.h public/xsm/% 
> public/%hvm/save.h, $(wildcard public/*.h public/*/*.h) $(public-y)) Makefile
> +PUBLIC_HEADERS_TO_CHECK := $(filter-out public/arch-% public/%ctl.h 
> public/xsm/% public/%hvm/save.h, $(wildcard public/*.h public/*/*.h) 
> $(public-y))
> +
> +headers.chk: $(PUBLIC_HEADERS_TO_CHECK) Makefile
>       for i in $(filter %.h,$^); do $(CC) -ansi -include stdint.h -Wall -W 
> -Werror -S -o /dev/null -x c $$i || exit 1; echo $$i; done >$@.new
>       mv $@.new $@
>  
> +headers++.chk: $(PUBLIC_HEADERS_TO_CHECK) Makefile

... I don't think limiting this to a subset of the headers is the right
thing here: C++ consumers are (most likely) going to be user space,
i.e. tools, and those would want to be able to use those excluded
headers.

> +     if g++ -v >/dev/null; then for i in $(filter %.h,$^); do g++ -ansi 
> -include stdint.h -Wall -W -Werror -S -o /dev/null -x c++ 
> -Dprivate=private_is_a_keyword_in_c_plus_plus $$i || exit 1; echo $$i; done ; 
> fi >$@.new

You may want to define __XEN_TOOLS__ (and un-define __XEN__)
here. Also g++ ought to by abstracted to $(CXX), and I don't see
how this step is being avoided when there's no C++ compiler there.

> --- a/xen/include/public/platform.h
> +++ b/xen/include/public/platform.h

These changes went in a few minutes ago.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.