1

I followed a video on LinkedIn to setup SFML, but when I tried compiling the code get several errors, some of which are:

  1. C2065 'Fullscreen': undeclared identifier
  2. C3861 'RenderWindow':identifier not found
  3. C2871 'sf': a namespace with this name does not exist
  4. C2653 'Style':is not a class or namespace name
  5. C2065 'VideoMode':undeclared identifier
  6. C3861 'vm' :identifier not found
  7. C2065 'vm' :undeclared identifier
  8. C26444 Don't try to declare a local variable with no name(es.84)
  9. C2146 syntax error:missing ';' before identifier 'vm' screenshot of the code and the compiler errors
2
  • Your bug is your don't have #include "pch.h" as the first line. In Visual Studio when using precompiled headers the compiler ignores every line above #include "pch.h" Commented Sep 2, 2020 at 13:10
  • 1
    Although, in this particular case, your 'bug' is apparent, you really should post your code as a (code-formatted) text block, rather than as an image. Otherwise, your question is likely to be closed as "Needs details or clarity!" I would recommend you edit your question to do that. Commented Sep 2, 2020 at 13:20

1 Answer 1

1

Assuming (from its name) that "pch.h" generates and/or uses the precompiled header for your build, then that has to be the very first header included in any source file. Otherwise, anything 'gleaned' from headers included before it will be lost, as the compiler only looks in that precompiled header and files included afterwards.

So, just rearrange your top three lines as follows:

#include "pch.h" // MUST be the first header included!
#include <iostream>
#include <SFML/Graphics.hpp>

For an interesting (and informative) discussion about precompiled headers in Visual Studio, see this Stack Overflow question, and the answers there: Precompiled Headers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.