I have a compiler (PGI) that does not support
#pragma once
but the library (thrust) I would like to include uses them.
Is there a workaround for this problem?
I have a compiler (PGI) that does not support
#pragma once
but the library (thrust) I would like to include uses them.
Is there a workaround for this problem?
You could use guardonce to convert the #pragma once
statements to standard #ifndef ...
include guards.
The following worked for me:
cd /tmp
git clone https://github.com/thrust/thrust.git
git clone https://github.com/cgmb/guardonce.git
cd guardonce
git checkout v2.0.0
python -m guardonce.once2guard -r "/tmp/thrust/thrust/"
This creates the include guards in every thrust header file:
git diff /tmp/thrust
--- a/thrust/adjacent_difference.h
+++ b/thrust/adjacent_difference.h
@@ -19,7 +19,8 @@
* \brief Compute difference between consecutive elements of a range
*/
-#pragma once
+#ifndef ADJACENT_DIFFERENCE_H
+#define ADJACENT_DIFFERENCE_H
. . .
Well, macros (and therefore #pragma) are handled by the preprocessor (cpp, not to be mistaken with c++ extension), so theoretically you could try using a preprocessor that supports #pragma, and then build the resulting code with your compiler.