Is #pragma once ok to use as a guard mechanism?
Hello,
sometimes I see guard mechanisms in .h files like so:
#ifndef _CLASSNAME_H_
#define _CLASSNAME_H_
...
#endif //(_CLASSNAME_H_)
doesnt "#pragma once" do the exact same thing but in one line of code? Why would anyone use the first method instead of "#pragma once" ?
Thank you,
Ellay
Re: Is #pragma once ok to use as a guard mechanism?
pragmas are not standard. -> if you want to be able to compile your code with different compilers it's better to use ordinary include guards.
kurt
Re: Is #pragma once ok to use as a guard mechanism?