![]() |
Pragma
So, I've seen the pre-processor command #pragma in several files and have heard people talking about it, but I haven't a clue what it does. Can anyone explain this to me? o_ô
|
Re: Pragma
|
Re: Pragma
#PRAGMA is a compiler directive. It is a way to pass information to the compiler that is not standard ANSI C. Because of that, there isn't any standard. One compiler may have a #PRAGMA command that doesn't work with any other compiler.
The post the Mike linked to is one example of a #PRAGMA for the C18 compiler. Another example is in this thread: http://www.chiefdelphi.com/forums/sh...ad.php?t=51550 Another example, for one project using Borland C, I used #PRAGMA pack to tell the compiler to byte align a particular structure, instead of word aligning it like default. If I were to try to move that code to another compiler, I would have to find out how to byte align structures with that compiler. You can find a full listing of all the #PRAGMA directives that the C18 compiler supports in the MPLAB C18 C Compiler User's Manual here: http://kevin.org/frc/C18_users_guide.pdf You can do a lot of neat things with #PRAGMA, but it's also one of the easiest ways to write non-portable code (not a big deal for our use, but it is in industry). |
| All times are GMT -5. The time now is 04:54. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi