UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 66541

2015.4 Vivado HLS - ***.h:193:7: error: expected unqualified-id before numeric constant

Description

I am encountering the following error in C simulation when I include "ap_int.h" as a header file:


   Compiling ../../../../cholesky_inverse_tb.cpp in debug mode
In file included from /proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ios:45:0,
                 from /proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/ostream:40,
                 from /proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/iostream:40,
                 from /proj/gsd/vivado/Vivado_HLS/2015.4/include/etc/ap_int_sim.h:76,
                 from /proj/gsd/vivado/Vivado_HLS/2015.4/include/ap_int.h:74,
                 from /proj/gsd/vivado/Vivado_HLS/2015.4/include/ap_fixed.h:67,
                 from /proj/gsd/vivado/Vivado_HLS/2015.4/include/hls/linear_algebra/hls_matrix_multiply.h:61,
                 from /proj/gsd/vivado/Vivado_HLS/2015.4/include/hls_linear_algebra.h:43,
                 from ../../../../cholesky_inverse.h:35,
                 from ../../../../cholesky_inverse_tb.cpp:32:
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h:193:7: error: expected unqualified-id before numeric constant
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h: In member function 'std::basic_ios<_CharT, _Traits>::operator void*() const':
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h:114:22: error: expected unqualified-id before numeric constant
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h:114:22: error: expected ';' before numeric constant
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h:114:27: error: '0' cannot be used as a function
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h: In member function 'bool std::basic_ios<_CharT, _Traits>::operator!() const':
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h:118:22: error: expected unqualified-id before numeric constant
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h:118:22: error: expected ';' before numeric constant
/proj/gsd/vivado/Vivado_HLS/2015.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/basic_ios.h:118:27: error: '0' cannot be used as a function

How do I resolve this issue?

Solution

In the example above, a macro is being declared that is conflicting with the header file.

For example, you have the following definition:

    #define fail 0

However, the header file "basic_ios.h", contains the following definition:

    bool
      fail() const
      { return (this->rdstate() & (badbit | failbit)) != 0; }

The preprocessor does not know how to interpret the code, and it replace "fail" with "0". As a result, this issue occurs.

To resolve this type of issue, be careful that your macro definition does not conflict with pre-defined keywords.

AR# 66541
Date Created 02/03/2016
Last Updated 02/05/2016
Status Active
Type General Article
Devices
  • FPGA Device Families
Tools
  • Vivado Design Suite