SFML community forums

Help => General => Topic started by: Ihatemylife on January 28, 2019, 07:11:47 pm

Title: WHY do I always get these errors (setting up SFML)
Post by: Ihatemylife 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...
Title: Re: WHY do I always get these errors (setting up SFML)
Post by: Laurent 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.
Title: Re: WHY do I always get these errors (setting up SFML)
Post by: eXpl0it3r 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.