May 8, 2019 at 11:31pm UTC
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 May 8, 2019 at 11:34pm UTC
May 9, 2019 at 12:19am UTC
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 May 9, 2019 at 12:23am UTC
May 9, 2019 at 12:34am UTC
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 May 9, 2019 at 12:36am UTC
May 9, 2019 at 12:53am UTC
Look very, very closely at the first two lines :)
May 9, 2019 at 1:24am UTC
Honestly I would have never spotted that on my own. Thanks!
May 9, 2019 at 1:36am UTC
You've also discovered why #pragma once was "invented"