• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
C Programming - Refresher - Part IV
 

C Programming - Refresher - Part IV

on

  • 329 views

C programming refresher from Embedded point of view. Fourth part talks about pre-processing

C programming refresher from Embedded point of view. Fourth part talks about pre-processing

Statistics

Views

Total Views
329
Views on SlideShare
326
Embed Views
3

Actions

Likes
0
Downloads
27
Comments
0

1 Embed 3

http://www.slideee.com 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    C Programming - Refresher - Part IV C Programming - Refresher - Part IV Presentation Transcript

    • C Refresher Team Emertxe Day4
    • Compiling a C program
    • Compilation  C program consists of source code in one or more files  Each source file is run through the preprocessor and compiler, resulting in a file containing object code  Object files are tied together by the linker to form a single executable program
    • Pre processing and macros
    • Preprocessing  Preprocessing • Occurs before program compiled • Inclusion of external files • Definition of symbolic constants • Macros • Conditional compilation • Conditional execution  All directives begin with # • Can only have whitespace before directives  Directives not C statements • Do not end with
    • #include  Usage  Loading header files • #include <stdio.h>  Programs with multiple source files  Header file • Has common declarations and definitions • structures, enumerations, function prototypes • Extract commonality of multiple program files
    • Symbolic constants  #define • Symbolic constants • Constants represented as symbols • When program compiled, all occurrences replaced  Format • #define identifier replacement-text • #define MAX_ARRAY_SIZE 30
    • Symbolic constants  Advantages • Takes no memory  Disadvantages • Name not be seen by debugger (only replacement text) • Do not have specific data type
    • Preprocessor directives - Macros  Macro • Operation specified in #define • Intended for legacy C programs • Macro without arguments • Treated like a symbolic constant  Macro with arguments • Arguments substituted for replacement text • Macro expanded • Performs a text substitution • No data type checking
    • Example #define PI 3.14159 #define CIRCLE_AREA( x ) ( PI * ( x ) * ( x ) ) area = CIRCLE_AREA( 4 ); becomes area = ( 3.14159 * ( 4 ) * ( 4 ) );
    • Preprocessor directives - Conditional compile  Control preprocessor directives and compilation  Cannot evaluate cast expressions, sizeof, enumeration #ifdef BOARD_TYPE_1 #define REG_SIZE 32 #else #define REG_SIZE 64 #endif
    • Stay connected About us: Emertxe is India’s one of the top IT finishing schools & self learning kits provider. Our primary focus is on Embedded with diversification focus on Java, Oracle and Android areas Emertxe Information Technologies, No-1, 9th Cross, 5th Main, Jayamahal Extension, Bangalore, Karnataka 560046 T: +91 80 6562 9666 E: training@emertxe.com https://www.facebook.com/Emertxe https://twitter.com/EmertxeTweet https://www.slideshare.net/EmertxeSlides
    • THANK YOU