Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

Compiler error for incorrect include order

FantasticMrFox
Beginner
1,753 Views

I have a program (attached) that has the following header order:

 

 

 

#include <CL/sycl/queue.hpp>
#include <CL/sycl/kernel_handler.hpp>
#include <CL/sycl/handler.hpp>
#include <CL/sycl/specialization_id.hpp>

 

 

 

If i put the header order as follows:

#include <CL/sycl/specialization_id.hpp>
#include <CL/sycl/queue.hpp>
#include <CL/sycl/kernel_handler.hpp>
#include <CL/sycl/handler.hpp>

 

when compiled gives a large error:

 

 

 

In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.cpp:1:
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.hpp:3:
/opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/specialization_id.hpp:11:1: error: unknown type name '__SYCL_INLINE_NAMESPACE'
__SYCL_INLINE_NAMESPACE(cl) {
^
/opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/specialization_id.hpp:12:1: error: expected expression
namespace sycl {
^
/opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/specialization_id.hpp:38:2: error: expected ';' after top level declarator
} // __SYCL_INLINE_NAMESPACE(cl)
 ^
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.cpp:1:
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.hpp:4:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/queue.hpp:11:
/opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/detail/assert_happened.hpp:21:25: error: redefinition of 'cl' as different kind of symbol
__SYCL_INLINE_NAMESPACE(cl) {
                        ^
/opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/specialization_id.hpp:11:25: note: previous definition is here
__SYCL_INLINE_NAMESPACE(cl) {
                        ^
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.cpp:1:
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.hpp:4:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/queue.hpp:12:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/detail/backend_traits.hpp:11:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/backend_types.hpp:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/fstream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/istream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/ios:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:39:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:79:11: error: no template named 'basic_string'; did you mean '__cxx11::basic_string'?
  typedef basic_string<char>    string;   
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:74:11: note: '__cxx11::basic_string' declared here
    class basic_string;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:83:11: error: no template named 'basic_string'; did you mean '__cxx11::basic_string'?
  typedef basic_string<wchar_t> wstring;   
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:74:11: note: '__cxx11::basic_string' declared here
    class basic_string;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:93:11: error: no template named 'basic_string'; did you mean '__cxx11::basic_string'?
  typedef basic_string<char16_t> u16string; 
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:74:11: note: '__cxx11::basic_string' declared here
    class basic_string;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:96:11: error: no template named 'basic_string'; did you mean '__cxx11::basic_string'?
  typedef basic_string<char32_t> u32string; 
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stringfwd.h:74:11: note: '__cxx11::basic_string' declared here
    class basic_string;
          ^
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.cpp:1:
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.hpp:4:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/queue.hpp:12:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/detail/backend_traits.hpp:11:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/backend_types.hpp:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/fstream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/istream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/ios:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:40:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/postypes.h:98:11: error: unknown type name 'ptrdiff_t'
  typedef ptrdiff_t     streamsize; // Signed integral type
          ^
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.cpp:1:
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.hpp:4:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/queue.hpp:12:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/detail/backend_traits.hpp:11:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/backend_types.hpp:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/fstream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/istream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/ios:38:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:147:11: error: no template named 'basic_stringbuf'; did you mean '__cxx11::basic_stringbuf'?
  typedef basic_stringbuf<char>         stringbuf;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:96:11: note: '__cxx11::basic_stringbuf' declared here
    class basic_stringbuf;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:150:11: error: no template named 'basic_istringstream'; did you mean '__cxx11::basic_istringstream'?
  typedef basic_istringstream<char>     istringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:100:11: note: '__cxx11::basic_istringstream' declared here
    class basic_istringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:153:11: error: no template named 'basic_ostringstream'; did you mean '__cxx11::basic_ostringstream'?
  typedef basic_ostringstream<char>     ostringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:104:11: note: '__cxx11::basic_ostringstream' declared here
    class basic_ostringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:156:11: error: no template named 'basic_stringstream'; did you mean '__cxx11::basic_stringstream'?
  typedef basic_stringstream<char>      stringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:108:11: note: '__cxx11::basic_stringstream' declared here
    class basic_stringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:187:11: error: no template named 'basic_stringbuf'; did you mean '__cxx11::basic_stringbuf'?
  typedef basic_stringbuf<wchar_t>      wstringbuf;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:96:11: note: '__cxx11::basic_stringbuf' declared here
    class basic_stringbuf;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:190:11: error: no template named 'basic_istringstream'; did you mean '__cxx11::basic_istringstream'?
  typedef basic_istringstream<wchar_t>  wistringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:100:11: note: '__cxx11::basic_istringstream' declared here
    class basic_istringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:193:11: error: no template named 'basic_ostringstream'; did you mean '__cxx11::basic_ostringstream'?
  typedef basic_ostringstream<wchar_t>  wostringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:104:11: note: '__cxx11::basic_ostringstream' declared here
    class basic_ostringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:196:11: error: no template named 'basic_stringstream'; did you mean '__cxx11::basic_stringstream'?
  typedef basic_stringstream<wchar_t>   wstringstream;
          ^
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/iosfwd:108:11: note: '__cxx11::basic_stringstream' declared here
    class basic_stringstream;
          ^
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.cpp:1:
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.hpp:4:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/queue.hpp:12:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/detail/backend_traits.hpp:11:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/backend_types.hpp:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/fstream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/istream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/ios:39:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/exception:143:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/exception_ptr.h:40:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/new:125:39: error: no type named 'size_t' in namespace 'std'; did you mean simply 'size_t'?
_GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
                                      ^~~~~
/opt/intel/oneapi/compiler/2022.1.0/linux/lib/clang/14.0.0/include/stddef.h:49:23: note: 'size_t' declared here
typedef __SIZE_TYPE__ size_t;
                      ^
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.cpp:1:
In file included from /home/ben/development/hovermap/src/gpu_common/examples/specialisation_constant.hpp:4:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/queue.hpp:12:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/detail/backend_traits.hpp:11:
In file included from /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/backend_types.hpp:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/fstream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/istream:38:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/ios:39:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/exception:143:
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/exception_ptr.h:40:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/new:127:41: error: no type named 'size_t' in namespace 'std'; did you mean simply 'size_t'?
_GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
                                        ^~~~~
/opt/intel/oneapi/compiler/2022.1.0/linux/lib/clang/14.0.0/include/stddef.h:49:23: note: 'size_t' declared here
typedef __SIZE_TYPE__ size_t;
                      ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/using_specialisation_constant.dir/build.make:63: CMakeFiles/using_specialisation_constant.dir/examples/specialisation_constant.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:628: CMakeFiles/using_specialisation_constant.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

 

 

 

 I think this is likely a bug, since header order should not matter. 

This is compiled with:

 

 

 

/opt/intel/oneapi/compiler/2022.1.0/linux/bin/dpcpp  -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"gpu_common\" -I/home/ben/development/hovermap/src/gpu_common/include -I/opt/ros/noetic/include -I/opt/ros/noetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp  -fclang-abi-compat=7 -fsycl --gcc-toolchain=/usr -sycl-std=2020 -fp-model=precise -Wall -Werror -fsycl  -O2 -g -DNDEBUG   -std=gnu++17 gpu_common/examples/specialisation_constant.cpp gpu_common/examples/using_specialisation_constant.cpp 

 

 

 

Labels (1)
0 Kudos
5 Replies
ShivaniK_Intel
Moderator
1,704 Views

Hi,


Thanks for posting in the Intel forums.


We are able to reproduce the issue on our end. We are working on it and will get back to you.


Thanks & Regards

Shivani






0 Kudos
ShivaniK_Intel
Moderator
1,675 Views

Hi,


The reason is that #include <CL/sycl.hpp> must be included in using_specialisation_constant.cpp and specialisation_constant.hpp.

Once it is included, you don't need the list of SYCL headers anymore.


Please let us know if you further face any issues.


Thanks & Regards

Shivani


0 Kudos
FantasticMrFox
Beginner
1,663 Views

This is not a satisfactory solution. You are breaking the cpp core guidelines. Header files should be self contained.

I have linked the guideline. By including all of sycl, not just the required headers, you are making our code take longer to compile as well. This is not particularly nice. 

 

With this solution you are also forcing us to break the core guideline: Avoid dependencies on implicity included header files.

 

We don't need this fixed now, but it is still a bug. 

0 Kudos
ShivaniK_Intel
Moderator
1,618 Views

Hi,


We are working on it and will get back to you .


Thanks & Regards

Shivani


0 Kudos
ShivaniK_Intel
Moderator
1,579 Views

Hi,


Thanks for your patience.


Our development team is working on it and will let you know once it is fixed.


Thanks & Regards

Shivani


0 Kudos
Reply