[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


...usage of #pragma and how can i direct the...

<< Back to: comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ)

Question by shaji kumar.V.K
Submitted on 2/26/2004
Related FAQ: comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ)
Rating: Rate this question: Vote
what is the usage of #pragma and how can i direct the compiler to use specific options?plz. explain with suitable examples.


Answer by harish
Submitted on 4/12/2004
Rating:  Rate this answer: Vote
# pragmas are the extended features provided with ur compiler.so there will be diffrent types.please check with ur compiler.

eg.most of the times u need to mix high level code with ur low level assembler code inorder to fine tune ur program either for faster execution or reducing memory usage.
so u can use # pragma asm and # pragma endasm in ur program

# include <stdio.h>

int main (void)
{
....

here u can have some main code

# pragma asm

  write the assemble code here
  movlw 25,w,0     e.g


# pragma endasm  this will end low level code


continue with main code here


}

 

Answer by Sibani
Submitted on 1/9/2007
Rating: Not yet rated Rate this answer: Vote
#pragma is also used to tell the compiler which part of the code is your ISR.
e.g.
#pragma interrupt
void start_ISR()
{
/* some code */
}
The above code tells your compiler that start_ISR is the ISR for your code.

Some other usage of #pragma is also for packing in structure fields.

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ)


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.