0

In my options class, I declare a static pointer of itself (there are other functions that have been removed to make it easier to read):

class Options {
public:
    std::string resourceFolder;

    static Options* o;


    int GetInt();
    std::string GetResourceFolder();
};

After this code, I received an unresolved external error as I had not defined the pointer. So I did that in my cpp file:

#include "Options.h"

Options* Options::o;

However, this should run without a compiler error. But, I receive the following error from the compiler:

fatal error C1001: An internal error has occurred in the compiler.

Is this a bug with the compiler? It also gives me the same error when I do not use a pointer (use a normal object declaration). A similar question can be found here

However the questions solution does not work for me.

EDIT

My compiler is visual studio 2017. I'm pretty sure its a Minimal, Complete, and Verifiable example.

Vitulus
  • 654
  • 4
  • 10
  • Can you reduce it to a [mcve]? Without it, we cannot conclude. If it is already a complete example, please say so in your question and if possible provide us with the compilation line. – YSC Jun 18 '18 at 09:02
  • Which compiler? – BartekPL Jun 18 '18 at 09:03
  • What compiler are you using? We can't tell you if the compiler is to blame without that tidbit of info. – StoryTeller - Unslander Monica Jun 18 '18 at 09:03
  • @YSC please read new edit – Vitulus Jun 18 '18 at 09:05
  • 1
    @StoryTeller I compile it with visual studio – Vitulus Jun 18 '18 at 09:06
  • 2
    [Here's a collection of people who encountered this error](https://stackoverflow.com/questions/7076494/fatal-error-c1001-an-internal-error-has-occurred-in-the-compiler). It's must likely some sort of project configuration error. Try what they did. – StoryTeller - Unslander Monica Jun 18 '18 at 09:07
  • @CowNecromancer "_I compile it with visual studio_" There are many versions of visual studio. Which one are you using? – Algirdas Preidžius Jun 18 '18 at 09:09
  • @StoryTeller I found that website before but for some reason didn't think the solutions would help me. Anyways, the solution of deleting the build folder fixed my problem. – Vitulus Jun 18 '18 at 09:09
  • That's one of the answers in the linked duplicate, specifically https://stackoverflow.com/a/45455677/15416. – MSalters Jun 18 '18 at 09:11
  • Yes an internal error in the compiler is always a compiler bug, the compiler should accept any code without crashing and either compile or reject it. If you are using the latest update of VS 2017 the click "report a problem" or post it to https://developercommunity.visualstudio.com/spaces/62/index.html. If you aren't using the latest VS 2017 updating may well solve your problem – Alan Birtles Jun 18 '18 at 09:12

0 Answers0