Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualsheep19

Posted 28 September 2012 - 11:53 AM

1) Do not use it in source files. Source files are not "included" anyway.
2) You should use it in every header file. If you don't, you are just asking for trouble. And no, there is no reason to include a header file more than once.
3) By using #pragma once you are not being "portable". That means your program is going to work only on windows, on the compiler that comes with visual studio (cl).
The correct (i.e. portable) way is to do it like this:
#ifndef SOME_FILE_H
#define SOME_FILE_H

// all your definitions here

#endif

#1sheep19

Posted 28 September 2012 - 11:52 AM

1) Do not use it in source files. Source files are not "included" anyway.
2) You should use it in every header file. If you don't, you are just asking for trouble. And no, there is no reason to include a header file more than once.
3) By using #pragma once you are not being "portable". That means your program is going to work only on windows, on the compiler that comes with visual studio (cl).
The correct way is to do it like this:
#ifndef SOME_FILE_H
#define SOME_FILE_H

// all your definitions here

#endif

PARTNERS