Thread: Pragma
View Single Post
  #3   Spotlight this post!  
Unread 11-02-2007, 02:16
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
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).

Last edited by Joe Ross : 11-02-2007 at 02:20.