pragma
directive
Saw this on Isaac ROS code at NVIDIA.
The pragma
directive is a special purpose directive and is used to turn on or off some features. They are compiler-specific.
Resources
- https://www.cprogramming.com/reference/preprocessor/pragma.html
- https://www.geeksforgeeks.org/pragma-directive-in-c-c/#
They use like this
pragma once
So apparently you can use #pragma once
instead of the #ifndef
.
The thing is that ifndef
is standardized, whereas pragma is compiler specific.
But this is what we do at NVIDIA at the top of every .hpp
file
#pragma once
Discussion