diff --git a/include/boost/preprocessor/stringize.hpp b/include/boost/preprocessor/stringize.hpp index 64dd5fd..e072dbd 100644 --- a/include/boost/preprocessor/stringize.hpp +++ b/include/boost/preprocessor/stringize.hpp @@ -28,6 +28,10 @@ # define BOOST_PP_STRINGIZE(text) BOOST_PP_STRINGIZE_I(text) # endif # +#if BOOST_PP_VARIADICS +# define BOOST_PP_STRINGIZE_I(...) #__VA_ARGS__ +#else # define BOOST_PP_STRINGIZE_I(text) #text +#endif # # endif diff --git a/include/boost/preprocessor/wstringize.hpp b/include/boost/preprocessor/wstringize.hpp index 5d1a83a..9f89673 100644 --- a/include/boost/preprocessor/wstringize.hpp +++ b/include/boost/preprocessor/wstringize.hpp @@ -23,7 +23,11 @@ # define BOOST_PP_WSTRINGIZE_OO(par) BOOST_PP_WSTRINGIZE_I ## par # endif # +#if BOOST_PP_VARIADICS +# define BOOST_PP_WSTRINGIZE_I(...) BOOST_PP_WSTRINGIZE_II(#__VA_ARGS__) +#else # define BOOST_PP_WSTRINGIZE_I(text) BOOST_PP_WSTRINGIZE_II(#text) +#endif # define BOOST_PP_WSTRINGIZE_II(str) L ## str # # endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 562ee9e..d0ad865 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -48,6 +48,7 @@ alias preprocessor [ compile selection.cpp : gcc:-std=c++0x clang-linux:-std=c++0x ] [ compile seq.cpp : gcc:-std=c++0x clang-linux:-std=c++0x ] [ compile slot.cpp : gcc:-std=c++0x clang-linux:-std=c++0x ] + [ compile stringize.cpp : gcc:-std=c++0x clang-linux:-std=c++0x ] [ compile tuple.cpp : gcc:-std=c++0x clang-linux:-std=c++0x ] [ compile variadic.cpp : gcc:-std=c++0x clang-linux:-std=c++0x ] ; @@ -67,6 +68,7 @@ alias preprocessor_nvm [ compile selection.cpp : BOOST_PP_VARIADICS=0 : selection_nvm ] [ compile seq.cpp : BOOST_PP_VARIADICS=0 : seq_nvm ] [ compile slot.cpp : BOOST_PP_VARIADICS=0 : slot_nvm ] + [ compile stringize.cpp : BOOST_PP_VARIADICS=0 : stringize_nvm ] [ compile tuple.cpp : BOOST_PP_VARIADICS=0 : tuple_nvm ] ; @@ -120,6 +122,10 @@ alias preprocessor_c : gcc:-std=c99 clang-linux:-std=c99 : slot_c ] + [ compile stringize.c + : gcc:-std=c99 clang-linux:-std=c99 + : stringize_c + ] [ compile tuple.c : gcc:-std=c99 clang-linux:-std=c99 : tuple_c @@ -187,6 +193,11 @@ alias preprocessor_c_nvm gcc:-std=c99 clang-linux:-std=c99 : slot_c_nvm ] + [ compile stringize.c + : BOOST_PP_VARIADICS=0 + gcc:-std=c99 clang-linux:-std=c99 + : stringize_c_nvm + ] [ compile tuple.c : BOOST_PP_VARIADICS=0 gcc:-std=c99 clang-linux:-std=c99 diff --git a/test/stringize.c b/test/stringize.c new file mode 100644 index 0000000..0ac19ec --- /dev/null +++ b/test/stringize.c @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2018. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/stringize.cpp b/test/stringize.cpp new file mode 100644 index 0000000..0ac19ec --- /dev/null +++ b/test/stringize.cpp @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2018. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/stringize.cxx b/test/stringize.cxx new file mode 100644 index 0000000..fb22128 --- /dev/null +++ b/test/stringize.cxx @@ -0,0 +1,36 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2018. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include +# include +# include +# include + +#define VDATA 1,2,3,4 +#define NDATA +#define DATA data +#define FDATA(x) BOOST_PP_INC(x) + +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() +BEGIN sizeof(BOOST_PP_STRINGIZE(NDATA)) / sizeof(char) == 1 END +BEGIN sizeof(BOOST_PP_WSTRINGIZE(NDATA)) / sizeof(wchar_t) == 1 END +#endif +BEGIN sizeof(BOOST_PP_STRINGIZE(DATA)) / sizeof(char) == 5 END +BEGIN sizeof(BOOST_PP_STRINGIZE(FDATA(1))) / sizeof(char) == 2 END +BEGIN sizeof(BOOST_PP_STRINGIZE(FDATA(9))) / sizeof(char) == 3 END +BEGIN sizeof(BOOST_PP_WSTRINGIZE(DATA)) / sizeof(wchar_t) == 5 END +BEGIN sizeof(BOOST_PP_WSTRINGIZE(FDATA(1))) / sizeof(wchar_t) == 2 END +BEGIN sizeof(BOOST_PP_WSTRINGIZE(FDATA(9))) / sizeof(wchar_t) == 3 END + +#if BOOST_PP_VARIADICS +BEGIN sizeof(BOOST_PP_STRINGIZE(VDATA)) / sizeof(char) == 8 END +BEGIN sizeof(BOOST_PP_WSTRINGIZE(VDATA)) / sizeof(wchar_t) == 8 END +#endif