diff mbox

[PATCHv2] linux-generic: debug: enable helper use from c++ programs

Message ID 20170201143022.11022-1-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Feb. 1, 2017, 2:30 p.m. UTC
The ODP_STATIC_ASSERT() macro expands to _Static_assert(), however when
used in C++ programs this needs to expand to static_assert().

This resolves Bug https://bugs.linaro.org/show_bug.cgi?id=2852

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
Changes for v2:
- Update C++ test case to include helper apis to validate this fix

 platform/linux-generic/include/odp/api/debug.h      | 6 ++++--
 test/common_plat/miscellaneous/odp_api_from_cpp.cpp | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.11.0.295.gd7dffce

Comments

Brian Brooks Feb. 1, 2017, 7:14 p.m. UTC | #1
On 02/01 08:30:22, Bill Fischofer wrote:
> The ODP_STATIC_ASSERT() macro expands to _Static_assert(), however when

> used in C++ programs this needs to expand to static_assert().

> 

> This resolves Bug https://bugs.linaro.org/show_bug.cgi?id=2852


I applied this patch and test/common_plat/miscellaneous/odp_api_from_cpp
fails to build. Verbose make output shows -std=c++11 is missing.
Does this compile for you?

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

> ---

> Changes for v2:

> - Update C++ test case to include helper apis to validate this fix

> 

>  platform/linux-generic/include/odp/api/debug.h      | 6 ++++--

>  test/common_plat/miscellaneous/odp_api_from_cpp.cpp | 2 +-

>  2 files changed, 5 insertions(+), 3 deletions(-)

> 

> diff --git a/platform/linux-generic/include/odp/api/debug.h b/platform/linux-generic/include/odp/api/debug.h

> index 7db14339..19659a9b 100644

> --- a/platform/linux-generic/include/odp/api/debug.h

> +++ b/platform/linux-generic/include/odp/api/debug.h

> @@ -39,9 +39,11 @@ extern "C" {

>   * if condition 'cond' is false. Macro definition is empty when compiler is not

>   * supported or the compiler does not support static assertion.

>   */

> -#define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg)

> +#ifndef __cplusplus

> +#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)

>  

> -#ifdef __cplusplus

> +#else

> +#define ODP_STATIC_ASSERT(cond, msg) static_assert(cond, msg)

>  }

>  #endif

>  

> diff --git a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

> index 2b307864..962b7fdc 100644

> --- a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

> +++ b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

> @@ -1,6 +1,6 @@

>  #include <cstdio>

>  #include <odp_api.h>

> -#include <odp/helper/threads.h>

> +#include <odp/helper/odph_api.h>

>  

>  int main(int argc ODP_UNUSED, const char *argv[] ODP_UNUSED)

>  {

> -- 

> 2.11.0.295.gd7dffce

>
Bill Fischofer Feb. 1, 2017, 8:25 p.m. UTC | #2
On Wed, Feb 1, 2017 at 1:14 PM, Brian Brooks <brian.brooks@linaro.org> wrote:
> On 02/01 08:30:22, Bill Fischofer wrote:

>> The ODP_STATIC_ASSERT() macro expands to _Static_assert(), however when

>> used in C++ programs this needs to expand to static_assert().

>>

>> This resolves Bug https://bugs.linaro.org/show_bug.cgi?id=2852

>

> I applied this patch and test/common_plat/miscellaneous/odp_api_from_cpp

> fails to build. Verbose make output shows -std=c++11 is missing.

> Does this compile for you?


Yes, it does. I'm using gcc 6.2.0 and clang 4.2.1 on Ubuntu 16.10.
What versions are you using? Did you specify --enable-test-cpp on
./configure?

>

>> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

>> ---

>> Changes for v2:

>> - Update C++ test case to include helper apis to validate this fix

>>

>>  platform/linux-generic/include/odp/api/debug.h      | 6 ++++--

>>  test/common_plat/miscellaneous/odp_api_from_cpp.cpp | 2 +-

>>  2 files changed, 5 insertions(+), 3 deletions(-)

>>

>> diff --git a/platform/linux-generic/include/odp/api/debug.h b/platform/linux-generic/include/odp/api/debug.h

>> index 7db14339..19659a9b 100644

>> --- a/platform/linux-generic/include/odp/api/debug.h

>> +++ b/platform/linux-generic/include/odp/api/debug.h

>> @@ -39,9 +39,11 @@ extern "C" {

>>   * if condition 'cond' is false. Macro definition is empty when compiler is not

>>   * supported or the compiler does not support static assertion.

>>   */

>> -#define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg)

>> +#ifndef __cplusplus

>> +#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)

>>

>> -#ifdef __cplusplus

>> +#else

>> +#define ODP_STATIC_ASSERT(cond, msg) static_assert(cond, msg)

>>  }

>>  #endif

>>

>> diff --git a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

>> index 2b307864..962b7fdc 100644

>> --- a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

>> +++ b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

>> @@ -1,6 +1,6 @@

>>  #include <cstdio>

>>  #include <odp_api.h>

>> -#include <odp/helper/threads.h>

>> +#include <odp/helper/odph_api.h>

>>

>>  int main(int argc ODP_UNUSED, const char *argv[] ODP_UNUSED)

>>  {

>> --

>> 2.11.0.295.gd7dffce

>>
Brian Brooks Feb. 2, 2017, 3:04 p.m. UTC | #3
On 02/01 14:25:32, Bill Fischofer wrote:
> On Wed, Feb 1, 2017 at 1:14 PM, Brian Brooks <brian.brooks@linaro.org> wrote:

> > On 02/01 08:30:22, Bill Fischofer wrote:

> >> The ODP_STATIC_ASSERT() macro expands to _Static_assert(), however when

> >> used in C++ programs this needs to expand to static_assert().

> >>

> >> This resolves Bug https://bugs.linaro.org/show_bug.cgi?id=2852

> >

> > I applied this patch and test/common_plat/miscellaneous/odp_api_from_cpp

> > fails to build. Verbose make output shows -std=c++11 is missing.

> > Does this compile for you?

> 

> Yes, it does. I'm using gcc 6.2.0 and clang 4.2.1 on Ubuntu 16.10.

> What versions are you using? Did you specify --enable-test-cpp on

> ./configure?


Yes, ./bootstrap ; ./configure --enable-test-cpp ; make -j

Ubuntu 16.04
gcc 5.4.0 20160609
binutils 2.26
autoconf 2.69
automake 1.15

Explicitly modifying program_{CPP,CXX,C}FLAGS in that program's Makefile.am
to use -std=c++11 resolves the build error related to use of static_assert
available in C++11 and beyond. But, it reveals another one related to
include paths.

Will try another machine. I hope it is not related to the versioning of
the Autotools...

> >

> >> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

> >> ---

> >> Changes for v2:

> >> - Update C++ test case to include helper apis to validate this fix

> >>

> >>  platform/linux-generic/include/odp/api/debug.h      | 6 ++++--

> >>  test/common_plat/miscellaneous/odp_api_from_cpp.cpp | 2 +-

> >>  2 files changed, 5 insertions(+), 3 deletions(-)

> >>

> >> diff --git a/platform/linux-generic/include/odp/api/debug.h b/platform/linux-generic/include/odp/api/debug.h

> >> index 7db14339..19659a9b 100644

> >> --- a/platform/linux-generic/include/odp/api/debug.h

> >> +++ b/platform/linux-generic/include/odp/api/debug.h

> >> @@ -39,9 +39,11 @@ extern "C" {

> >>   * if condition 'cond' is false. Macro definition is empty when compiler is not

> >>   * supported or the compiler does not support static assertion.

> >>   */

> >> -#define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg)

> >> +#ifndef __cplusplus

> >> +#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)

> >>

> >> -#ifdef __cplusplus

> >> +#else

> >> +#define ODP_STATIC_ASSERT(cond, msg) static_assert(cond, msg)

> >>  }

> >>  #endif

> >>

> >> diff --git a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

> >> index 2b307864..962b7fdc 100644

> >> --- a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

> >> +++ b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp

> >> @@ -1,6 +1,6 @@

> >>  #include <cstdio>

> >>  #include <odp_api.h>

> >> -#include <odp/helper/threads.h>

> >> +#include <odp/helper/odph_api.h>

> >>

> >>  int main(int argc ODP_UNUSED, const char *argv[] ODP_UNUSED)

> >>  {

> >> --

> >> 2.11.0.295.gd7dffce

> >>
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp/api/debug.h b/platform/linux-generic/include/odp/api/debug.h
index 7db14339..19659a9b 100644
--- a/platform/linux-generic/include/odp/api/debug.h
+++ b/platform/linux-generic/include/odp/api/debug.h
@@ -39,9 +39,11 @@  extern "C" {
  * if condition 'cond' is false. Macro definition is empty when compiler is not
  * supported or the compiler does not support static assertion.
  */
-#define ODP_STATIC_ASSERT(cond, msg)  _Static_assert(cond, msg)
+#ifndef __cplusplus
+#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
 
-#ifdef __cplusplus
+#else
+#define ODP_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
 }
 #endif
 
diff --git a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp
index 2b307864..962b7fdc 100644
--- a/test/common_plat/miscellaneous/odp_api_from_cpp.cpp
+++ b/test/common_plat/miscellaneous/odp_api_from_cpp.cpp
@@ -1,6 +1,6 @@ 
 #include <cstdio>
 #include <odp_api.h>
-#include <odp/helper/threads.h>
+#include <odp/helper/odph_api.h>
 
 int main(int argc ODP_UNUSED, const char *argv[] ODP_UNUSED)
 {