Trouble compiling in VS2017 RC.

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
edge
Posts: 1
Joined: January 21st, 2017, 9:01 am

Trouble compiling in VS2017 RC.

Post by edge » January 21st, 2017, 9:10 am

Just started the beginner guide to c++ game dev series from 2016.
When trying to compile, VS2017 RC will sometimes (seems totally random) stop at lines 102-111 in colors.h.

The error message is: "function call must have a constant value in a constant expression".

It's like the MakeRGB-function doesn't accept the values given (255u,255u,255u) etc.

Changing line 98 in colors.h (changing the char to int)
static constexpr Color MakeRGB( unsigned char r,unsigned char g,unsigned char b )
to
static constexpr Color MakeRGB( unsigned int r,unsigned int g,unsigned int b )

seems to alleviate the problem, but I don't want to fuck things up.

Any tips on how to get around this without breaking shit? :ugeek:

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Trouble compiling in VS2017 RC.

Post by albinopapa » January 21st, 2017, 11:18 am

If you keep the line the same:

Code: Select all

static constexpr Color MakeRGB( unsigned char r,unsigned char g,unsigned char b )
for the unsigned char values, instead of 255u, change to 255ui8.

Code: Select all

static constexpr Color Red = MakeRGB(255ui8, 0ui8, 0ui8);
The ui8 at the end, means unsigned eight bit int...ie unsigned char.

I didn't have trouble compiling the 2016 framework in VS2017, but intellisense kept saying the values wouldn't fit, but that was because I was trying to pass in a float. That brings me to the next issue, make sure you pass in unsigned chars and not int, unsigned int or float to the MakeRGB or Color constructor.

I'm guessing the standards committee is getting more string about implicit conversions.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Trouble compiling in VS2017 RC.

Post by chili » January 22nd, 2017, 8:16 am

I personally recommend waiting until full release to start using VS2017 in earnest. You can experiment, but if you are still learning C++, adding one more factor to mess things up (an unfinished / potentially buggy environment) isn't going to help matters.
Chili

Post Reply