Epic Fail when trying to use orangered color!

Okay so for some reason this line returns a bug:

Code:
SDL_MapRGB(screen->format,255,069,0);

Please note I am using the latest Codeblocks on windows vista and minigw compiler.

The error returned is this:

||=== Game, Debug ===|
|invalid digit “9” in octal constant|
||=== Build finished: 1 errors, 0 warnings ===|

Any reason why this can not work?

Hello!

My initial guess would be the fact you are writing the second number as 069 rather than 69.
According to MSDN:
http://msdn.microsoft.com/en-us/library/2k2xf226(v=vs.80).aspx

For hexadecimal, you’d prefix it with 0x. Likewise, for Octal, you prefix it with a 0. Octal only supports 0 - 7 so when the compiler sees the 9, it errors out saying that 9 is not a valid octal digit.

I hope that helps!

theweirdn8 wrote:> Okay so for some reason this line returns a bug:

Code:
SDL_MapRGB(screen->format,255,069,0);

Please note I am using the latest Codeblocks on windows vista and minigw compiler.

The error returned is this:

||=== Game, Debug ===|
|invalid digit “9” in octal constant|
||=== Build finished: 1 errors, 0 warnings ===|

Any reason why this can not work?

thank you. It now works. I was trying to make everything with 3 digits, but I guess it doesn’t have to look pretty and such.

Uhm…

Because 9 is not a valid OCTAL digit?

  • Steve M.> ----- Original Message -----

From: staff@tailware.com (theweirdn8)
Date: Thursday, Feb 24, 2011 9:40 pm
Subject: [SDL] Epic Fail when trying to use orangered color!
To: sdl at lists.libsdl.orgReply-To: sdl at lists.libsdl.org

	 	Okay so for some reason this line returns a bug:

Code:

SDL_MapRGB(screen->format,255,069,0);

Please note I am using the latest Codeblocks on windows vista and minigw compiler.

The error returned is this:

Quote:

||=== Game, Debug ===|
|invalid digit “9” in octal constant|
||=== Build finished: 1 errors, 0 warnings ===|

Any reason why this can not work?

Because the C compiler sees a leading 0 in your number and thinks you’re writing
it in octal, not decimal. Write 69 instead of 069 and it will work.________________________________
From: staff@tailware.com (theweirdn8)
Subject: [SDL] Epic Fail when trying to use orangered color!

Okay so for some reason this line returns a bug:

Code:

SDL_MapRGB(screen->format,255,069,0);

Please note I am using the latest Codeblocks on windows vista and minigw
compiler.

The error returned is this:

Quote:

||=== Game, Debug ===|
|invalid digit “9” in octal constant|
||=== Build finished: 1 errors, 0 warnings ===|

Any reason why this can not work?

This is actually SDL trying to protect the user against tasteless colors. For example, it’s now winter and soon spring, but orangered would be more of an autumn color. Hence SDL gives this compiler error.

It may appear to be a bit inconvenient, but it improves the style in the long term!

/joking

theweirdn8 wrote:> Okay so for some reason this line returns a bug:

Code:
SDL_MapRGB(screen->format,255,069,0);

Please note I am using the latest Codeblocks on windows vista and minigw compiler.

The error returned is this:

||=== Game, Debug ===|
|invalid digit “9” in octal constant|
||=== Build finished: 1 errors, 0 warnings ===|

Any reason why this can not work?