what is #pragma

So I have been trying to figure out what #pragma does. It looks like it calls some libraries but I am not sure. If it is calling libraries, what are available libraries for use and what do these libraries do?

 #pragma strict
 #pragma implicit
 #pragma downcast

Thanks in advance everyone!

more ▼

asked Sep 03, 2011 at 09:45 PM

avatar image

Diet Chugg
479 69 64 81

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

pragma is a pre-compiler directive. ie it tells the compiler what to do or how to behave.

eg #strict - "be uptight when you compile this schizzle bro!"

more ▼

answered Sep 03, 2011 at 11:57 PM

avatar image

61 4 3 4

They're also very helpful in optimizing your game.

Sep 04, 2011 at 12:01 AM unluckyBastard

how are they helpful in optimizing?

Sep 04, 2011 at 01:53 AM Diet Chugg

by being strict. they won't allow you to do as dirty code.

e.g. when defining a variable without #pragma you can leave out the typing and unity will figure out what the variable 's supposed to be when you use it. But the 'figuring out'-part can take a lot of resources. That's why it's considered bad habit / dirty code to not always type stuff. With #pragma you must tell of what type the variable will be and it will give you an error if you don't comply.

Greetz, Ky.

Sep 06, 2011 at 08:27 PM SisterKy

Greta, now I now... the new version of MonoDevelop includes #pragma strict on all new scripts. This will keep me on my toes ;-)

Feb 17, 2012 at 01:29 AM POLYGAMe

It's Unity 3.5 that includes #pragma strict for new scripts, not MonoDevelop.

Feb 17, 2012 at 01:45 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Sep 03, 2011 at 09:45 PM

Seen: 6840 times

Last Updated: Jun 10, 2013 at 03:32 PM