Skip to main content
gamedev.net
🔒 Locked

pragma?

Started by kelaklub 10 replies 600+ views
Original Post
kelaklub
kelaklub
I was looking at the code from Watt''s and Policarpo''s 3d games book and in his vector/matrix code I saw something that went like this in the very top line of his code...
#pragma(16)     // 16 byte allocation 
what the heck is "pragma"? Thank you.
felisandria
felisandria
"pragma" is a compiler directive used by the preprocessor. It''s a macro definition like, say, #define.

If you want to know what a specific one does you have to look it up.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Sneftel
Sneftel
A bit more info: the C/C++ standards define #pragma as completely implementation specific. That is to say, each compiler developer is free to do whatever they want with #pragma; it''s used for "extensions" to the language that are not in the standard, stuff like structure padding, optimization hints, etc. So you''ll need to check the documentation for your individual compiler for more info.


How appropriate. You fight like a cow.
JY
JY
And if you want to get rid of those annoying compiler warnings you can use:

#pragma warning(disable:4244)


"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
kelaklub
kelaklub
The reason I ask is because the vector/matrix class they have implemented uses SIMD assembly instructions and if your compiler does not support them, then regular old c++ instructions are used to compute a vector times a scalar, etc. Does it really matter these days, or can you just code using c++, or would assembly really make a significant boost in a part of your code that is probably going to be called alot?

[edited by - kelaklub on July 23, 2003 3:52:05 PM]
Sneftel
Sneftel
You''ll never know until you profile your code.
RapidStunna
RapidStunna
Hmm that made me wonder. Does the library linking (#pragma comment(lib,"")) work on most compilers? My game engine, which will later be open-source, uses that compiler directive. Is that safe?

---
Brent Gunning | My Site
Yohumbus
Yohumbus
Is could be considered safe and you can certainly keep them there (the pragma''s shouldn''t do anything if they are not supported) but be sure to tell how to link those libraries via command line.
ASCII stupid question, get a stupid ANSI
zealouselixir
zealouselixir
Dev-C++ ignores "#pragma comment (lib, ...)", so be careful.
[twitter]warrenm[/twitter]
RapidStunna
RapidStunna
Okay I understand. So I''ll include the pragma directive, but I will make sure that non-VC++ users must link the libraries in manually. Are there any MINGW or BORLAND compiler directives to do the same? just so it makes engine usage easiest.

---
Brent Gunning | My Site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.