-
Notifications
You must be signed in to change notification settings - Fork 7
Support C++ translation units #3
Description
Immintrin-debug is implemented in C which is also desired (given that C code should be able to make use of this project). However, using the Immintrin-debug header file in a C++ translation unit will cause at least compiler errors (as C++ is less permissive). Anyhow, a lot of warnings are also present with C code at higher warning levels (let alone extra and/or pedantic warnings).
How to reproduce:
- Git-clone the master revision of LIBXSMM: git clone https://github.com/hfp/libxsmm.git
- Copy immintrin_dbg.h to include directory: cp immintrin_dbg.h /path/to/libxsmm/include
- Edit https://github.com/hfp/libxsmm/blob/master/include/libxsmm_intrinsics_x86.h#L37 (0 -> 1)
To translate using a C++ translation unit:
- cd /path/to/libxsmm; make test-cpp
To compile with a lot of warning flags:
- C++ translation: cd /path/to/libxsmm; make PEDANTIC=2 test-cpp
- C89 translation: cd /path/to/libxsmm; make PEDANTIC=2
Immintrin-debug may switch to some more sophisticated function-decoration at least with respect to "static" and "inline" (different meanings in C++ and C; for the latter "inline" for instance was only introduced in C99 and may be emulated prior to this standard).
I understand that not all of the above warnings will be resolved easily (nor they should as effort is not justified). However, it should work with C++ translation units.
Btw, compilers (regardless of C and C++) may or may not allow intrinsics with/without prototype functions plus if prototypes are present they may differ slightly between Intel and GNU intrinsic headers (aka void* vs e.g. float* in some places etc.). For the latter, casts may assume target signature with float* (or stronger type in general) even if say Intel's prototype has void* (assuming the stronger type works with any compiler as type-"promotion" [demotion] to void* is applied automatically and considered safe).