About preprocessor statement

Why #pragma() is used in C programming? What is meant by structure padding in C programming? How is this related to pragma directive? Please do reply.

Replies

  • xxxabhash007
    xxxabhash007
    When a pragma is encountered in source code, it overrides the behavior specified by the compiler option.
  • anandkumarjha
    anandkumarjha
    vijaymp
    Why #pragma() is used in C programming? What is meant by structure padding in C programming? How is this related to pragma directive? Please do reply.
    _Pragma (and #pragma, which does the same sort of
    thing but with different syntax) has two effects on your
    code.
    We use #pragma or _pragma to tell the compiler something that c language can not express itself:like this function naver returns any value or it does not have any side effect
  • Nupin
    Nupin
    #pragma is used to execute a function before main() funtion get executed..
    visit: Coding Tricks: To execute a function before the main() get executed
  • Mallory
    Mallory
    macro definitions (#define, #undef)

    To define preprocessor macros we can use #define. Its format is:
    #define identifier replacement

    When the preprocessor encounters this directive, it replaces any occurrence of identifier in the rest of the code by replacement. This replacement can be an expression, a statement, a block or simply anything. The preprocessor does not understand C++, it simply replaces any occurrence of identifier by replacement.

    #define TABLE_SIZE 100int table1[TABLE_SIZE];int table2[TABLE_SIZE];
    After the preprocessor has replaced TABLE_SIZE, the code becomes equivalent to:

    int table1[100];int table2[100];
    This use of #define as constant definer is already known by us from previous tutorials, but #define can work also with parameters to define function macros:

    #define getmax(a,b) a>b?a:b

You are reading an archived discussion.

Related Posts

hi all. i want to know about various national and international competitions in field of engineering. any good website address would be nice. and also please enllist competitions which can...
The World's Leading Trade Fair for the Automotive Industry 14 to 19 September 2010! Automechanika 2010
hello. i want to know that, what are the essential courses a computer student should have side by side to his studies? and which is most useful language today from...
namaste, here all of you. a thought of mobile app especially made for CE striked me today. but my all sins came across me, coz uptill now I DONT KNOW...
Lot of engineering students and professionals are concerned about 'career'. I wish to know what does 'career' mean to you? Is it your job or something else?