Jump to content

  • Log In with Google      Sign In   
  • Create Account

expression in struct possible?


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
7 replies to this topic

#1   Members   

4632
Like
0Likes
Like

Posted 28 February 2013 - 03:21 PM

Hi,

I'm trying to make a switch including expressions, but the compiler unfortunately doesn't  'eat it'.

 

The code/ thing I'm trying:

 

switch (pNrPointLights)
{
	case <=4: // do stuff
	case >4 && <=8: // do other stuff
}

Is this possible in C++ switches?


Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me


#2   Senior Moderators   

12537
Like
0Likes
Like

Posted 28 February 2013 - 03:24 PM

Nope. Try 'if' statements.


Edited by Promit, 28 February 2013 - 03:26 PM.

SlimDX | Shark Eaters for iOS | Ventspace Blog | Twitter | Proud supporter of diversity and inclusiveness in game development

#3   GDNet+   

6360
Like
0Likes
Like

Posted 28 February 2013 - 03:28 PM

switch's only choose a value, the can't evaluate expressions for cases.


Edited by slicer4ever, 28 February 2013 - 03:29 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#4   Members   

4632
Like
0Likes
Like

Posted 28 February 2013 - 03:44 PM

thanks for the quick answers, will go for if statements in this case.


Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me


#5   Members   

1809
Like
0Likes
Like

Posted 28 February 2013 - 05:23 PM

switch's only choose a value, the can't evaluate expressions for cases.

Yes, although simple arithmetic expressions that can be evaluated at compile time may be supported.


And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#6   Members   

4632
Like
0Likes
Like

Posted 01 March 2013 - 12:10 PM

Hi geometrian,

Can you explain a bit more on what you mean?


Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me


#7   Members   

8966
Like
0Likes
Like

Posted 01 March 2013 - 12:27 PM

That means expressions with only literals or enumeration values that result in a single integer value, such as case FOO + 1:.

The expression in switch can be (almost) whatever you want, but anything after case needs to be a single constant integer (or something that trivially results in that). So, no comparisons, no boolean logic, no function calls, etc. -- integers, like 5 or 8, or 7123, or 213+5.

#8   Members   

4632
Like
0Likes
Like

Posted 01 March 2013 - 04:40 PM

Thanks, i understand now

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.