Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

expression in struct possible?

4: Adsense

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 cozzie   Members   

4970
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 Promit   Senior Moderators   

13101
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 slicer4ever   GDNet+   

6673
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 cozzie   Members   

4970
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 Geometrian   Members   

1810
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 cozzie   Members   

4970
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 samoth   Members   

9655
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 cozzie   Members   

4970
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.