header guards and #pragma once

hi,

Is it necessary to use both header guards and #pragma once sometimes? I ask because I now have a class that explodes without #pragma once even though I have had guards in place.
edit: I just seems weird to me

thanks
Last edited on
Can you paste the header file giving problems?

#pragma once is non-standard, but supported by mainstream compilers (gcc, clang, msvc). Using both can't hurt.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
#ifndef SQAUD_H
#define SQUAD_H
#pragma once
#include "Person.h"
#include <array>
#include "Movement.h"
#include "Toolbox.h"
#include "Direction.h"
class Squad
{};
#endif  


edit: I don't think the contents of the class would matter here so I omitted them
Last edited on
Look very, very closely at the first two lines :)
Honestly I would have never spotted that on my own. Thanks!
You've also discovered why #pragma once was "invented"

Topic archived. No new replies allowed.