The compiler does not support #pragma once
I have a compiler (PGI) that does not support
#pragma once
but the library (pull) I would like to include is using them.
Is there a workaround for the problem?
+3
user1928546
source
to share
2 answers
You can use guardonce to convert statements #pragma once
to standard #ifndef ...
include guard.
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 included 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
. . .
+2
ms
source
to share
Well macros (and therefore #pragma) are preprocessing (cpp so as not to go wrong with the C ++ extension), so in theory you could try using a preprocessor that supports #pragma and then build the resulting code with the compiler.
+1
Teyras
source
to share