Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: WHY do I always get these errors (setting up SFML)  (Read 2061 times)

0 Members and 1 Guest are viewing this topic.

Ihatemylife

  • Newbie
  • *
  • Posts: 1
    • View Profile
WHY do I always get these errors (setting up SFML)
« on: January 28, 2019, 07:11:47 pm »
Hi I'm new to VS 2017 and SFML and I now tried to set up SFML for the 8th time without proper results. I always get the error:
C2589   '(': illegal token on right side of '::'   NO c:\users\user\source\repos\no\sfml\include\sfml\graphics\rect.inl   81   

I followed many tutorials several times including the official tutorial at https://www.sfml-dev.org/tutorials/2.5/start-vc.php

this is everything I coded so far, so that can't be problem.

#include "stdafx.h"

#include <SFML/Graphics.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Graphics.hpp>

int main()
{

}

Its extremely frustrating and I dont know what to do anymore.
Any help would be appreciated...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: WHY do I always get these errors (setting up SFML)
« Reply #1 on: January 28, 2019, 07:51:51 pm »
Don't use stdafx.h if you don't know how to properly use it. It includes unnecessary stuff, especially <windows.h> which defines the 'min' and 'max' macros that mess up with SFML inline source code (in Rect.inl).

If you do need windows.h in your final source code, then the solution is to define the NOMINMAX preprocessor symbol in your project settings.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: WHY do I always get these errors (setting up SFML)
« Reply #2 on: January 28, 2019, 07:53:59 pm »
I recommend creating a new "Empty Project" then follow the tutorial step by step and only include the SFML headers once.

The problem is most likely that stdafx.h is including windows.h which defines the macros min and max, which then replace the std::mind and std::max calls in Rect.inl with something that then fails to compile.
If you want to keep using stdafx.h or windows.h you should define NOMINMAX before including windows.h.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/