Friday, July 31, 2009

Can anyone explain me about the pragma in c/c++?

Can any oneplease explain me about the usage of pragma in c/c++ with example.(or atlease provide me a link where i can learn through some examples)





Thanks in advance

Can anyone explain me about the pragma in c/c++?
#pragma is for setting compiler related options inside the source files themselves. As you probably know already, each project has its own compilation settings. Many times, these global settings need to be altered when compiling a certain file, i.e. global compiler settings are telling the compiler to optimize the size of the resulting object, but on a certain file you want to tell the compiler to optimize its speed, so you would use;





#pragma optimize("t", on) // tells the compiler to optimize for speed, a VC++ directive


//YOUR LINES OF CODE HERE
Reply:An instruction to the compiler to compile your program in a certain way. For example, you can use pragmas to insert copyright information into your object files, to specify a particular template instantiation, and to specify optimization levels. A pragma always begins with a number sign (#).
Reply:It's often used to suppress compiler warnings.


No comments:

Post a Comment