SlideShare a Scribd company logo
1 of 16
The C Language
 An International Standard


           CIS2450
Professional Aspect of Software
         Engineering
                                  1
ANSI C
• The C language appeared in the early 1970s and
  was originally cryptic, small, and tolerant. For the
  next ten years C evolved in the UNIX
  environment.
• The resultant language was first described in the
  paper “Portability of C Programs and the UNIX
  System,” by S.C. Johnson and Dennis Ritchie in
  1978.
• This style of C was commonly called UNIX C.
                                                     2
ANSI C
• In 1989 the American National Standards Institute
  (ANSI) standardized C as standard X3.159-1989.
• In December of that year the International
  Standards Organization ISO adopted the ANSI C
  standard making minor changes.
• In 1990 ANSI then re-adopted ISO standard C.
• This version of C is known as either ANSI C or
  Standard C.

                                                  3
Implementation Characteristics
• The ANSI standard defines several terms which
  describe the characteristics of an implementation.
  They are useful to describe what is and is not
  acceptable in the language.
• Implementation defined code means that the
  compiler writer chooses what happens and has to
  document it.
   – Example: whether the sign bit is propagated when
     shifting a bit right.

                                                        4
Implementation Characteristics
• Unspecified behavior for something correct
  which the standard does not impose any
  requirements.
   – Example: the order of argument evaluation.
• Undefined behavior is something incorrect which
  the standard does not impose any requirements.
  Anything may happen, from nothing, to a warning
  message, to program termination.
   – Example: what happens when a signed integer
     overflows.
                                                   5
Implementation Characteristics
• A constraint is a restriction or requirement
  which must be obeyed. If you do not then
  your program will become undefined.
  – Example: the operands of the % operator must
    be of integral type or a diagnostic will result.
• An interesting problem with the definition
  of constraints is that compilers only have to
  produce an error message if a program
  violates both syntax and constraints.
                                                       6
Implementation Characteristics
• Semantic rules which are not explicitly
  stated can be broken and because this
  behavior is undefined the compiler does not
  have to issue a warning.
  – Example: the C standard header files have a
    function called malloc, but redefining this
    function is not a constraint so the compiler does
    not have to warn if this happens.

                                                    7
Implementation Characteristics
• Strictly conforming code is one which:
   – uses only specified features
   – doesn't exceed any implementation-defined limit
   – has no output that depends on implementation defined,
     unspecified, or undefined features
• This is not a very interesting class because there
  are so few programs which meet the criteria.



                                                             8
Implementation Characteristics
• Conforming programs can depend on non-
  portable features.
• A conforming program is considered with
  respect to a specific implementation and
  may be non-conforming using a different
  compiler. It can have extensions, but not
  ones which alter the behavior of a strictly
  conforming program.
                                                9
ANSI Changes to (older) C
• A variety of minimum sizes were defined
  by the standard including:
  –   31 parameters in a function definition
  –   31 arguments in a function call
  –   509 characters in a source line
  –   32 levels of nested parentheses in an expression
  –   long ints are at least 32 bits

                                                     10
Differences between ANSI and
              K&R
• Prototype change
  – parameters must be written in the function
    declaration, not just the definition.
• Keyword changes
  – several new keywords were added including
    enum, const, volatile, signed, and void.



                                                 11
Differences between ANSI and
             K&R
• Quiet changes
  – which are mostly minor changes which cause code to
    still compile but perhaps operate in a different manner.
• Everything else
  – these changes will have almost no effect and will
    almost never be encountered in practice, e.g. trigraphs
    can be used to represent a single character by using
    three characters, so ??< represents {


                                                              12
New Features of C99
• Coding
  – end-of-line (//) comments like C++
  – Mix declarations and code
  – Remove implicit function declaration
• Data types
  – long long int (minimum 64bit Integer)
  – Variable length arrays
  – Flexible array members of structures
• Library
  – snprintf family of functions in stdio.h
                                              13
Why Do We Care about Older C?
• For new development, we don’t, but…
• Huge installed code base is “old”
   – Many jobs involve maintenance of legacy code
   – Avoid misunderstanding legacy code
      • Based on your new-C habits
   – Avoid introducing bugs into legacy code
      • Keep to legacy coding style for consistency
• Choices: retain older C compiler or try to upgrade
  to new compiler standard (exposes “code rot”)
                                                      14
What is “code rot”?
• Aka “software rot” “bit rot”
• When program hasn’t been changed,
  yet stops working/compiling
  – Earlier assumptions no longer valid (e.g.,
    famous Y2K bug → 2 bytes no longer enough)
  – Compiler, libraries, or operating system
    “upgraded,” features discontinued or
    incompatible
                                             15
Holding Code Rot at Bay
• Recognize assumptions that won’t stand test of
  time
   – “Users will never need more than 32767 records, so 16-
     bit index is fine!” (+1 looks <0) → Comair fiasco
• Write strictly-conforming software, not relying on
  extensions or “tricks”
   – E.g., intentionally accessing outside array bounds
• Recompile when language spec revised, system
  upgraded, etc.
   – May discover small problems, easily fixed
   – Or BIG problems needing major reexamination
                                                          16

More Related Content

What's hot (20)

Interpreters & Debuggers
Interpreters  &  DebuggersInterpreters  &  Debuggers
Interpreters & Debuggers
 
COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis: COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis:
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Compiler design
Compiler designCompiler design
Compiler design
 
Language processor
Language processorLanguage processor
Language processor
 
Introduction to Compiler
Introduction to CompilerIntroduction to Compiler
Introduction to Compiler
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Compiler design tutorial
Compiler design tutorialCompiler design tutorial
Compiler design tutorial
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
Advanced C - Part 1
Advanced C - Part 1 Advanced C - Part 1
Advanced C - Part 1
 
An overview of computers and programming languages
An overview of computers and programming languages An overview of computers and programming languages
An overview of computers and programming languages
 
Programming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwaresProgramming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwares
 
Principles Of Programing Languages
Principles Of Programing LanguagesPrinciples Of Programing Languages
Principles Of Programing Languages
 
Cd unit i
Cd unit iCd unit i
Cd unit i
 
Compiler design tutorial
Compiler design tutorialCompiler design tutorial
Compiler design tutorial
 
JIT Compiler
JIT CompilerJIT Compiler
JIT Compiler
 

Viewers also liked

Singleton is not_the_only_pattern
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_patternSeb Rose
 
OnSpotAward_TDMS_team
OnSpotAward_TDMS_teamOnSpotAward_TDMS_team
OnSpotAward_TDMS_teamAbhinav Vatsa
 
Intervensi biology Form 5 chapter 2
Intervensi biology Form 5 chapter 2Intervensi biology Form 5 chapter 2
Intervensi biology Form 5 chapter 2Nirmala Josephine
 
01 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_0101 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_01Niit Care
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1Innovative
 
CCNA Interview Questions and Answer ppt - JavaTpoint
CCNA Interview Questions and Answer ppt - JavaTpointCCNA Interview Questions and Answer ppt - JavaTpoint
CCNA Interview Questions and Answer ppt - JavaTpointJavaTpoint.Com
 
BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5
BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5
BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5Nirmala Josephine
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic conceptsAbhinav Vatsa
 
Coordination & Response Part 1 - The Nervous System
Coordination & Response Part 1 - The Nervous SystemCoordination & Response Part 1 - The Nervous System
Coordination & Response Part 1 - The Nervous SystemNirmala Josephine
 
Wireless technology from 0G to 7.5G
Wireless technology from 0G to 7.5GWireless technology from 0G to 7.5G
Wireless technology from 0G to 7.5GShashikanth M
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)Olve Maudal
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by ExampleOlve Maudal
 
Overview of c language
Overview of c languageOverview of c language
Overview of c languageshalini392
 

Viewers also liked (20)

Singleton is not_the_only_pattern
Singleton is not_the_only_patternSingleton is not_the_only_pattern
Singleton is not_the_only_pattern
 
C Standards: main()
C Standards: main()C Standards: main()
C Standards: main()
 
OnSpotAward_TDMS_team
OnSpotAward_TDMS_teamOnSpotAward_TDMS_team
OnSpotAward_TDMS_team
 
7g
7g7g
7g
 
Intervensi biology Form 5 chapter 2
Intervensi biology Form 5 chapter 2Intervensi biology Form 5 chapter 2
Intervensi biology Form 5 chapter 2
 
C programming tutorial for beginners
C programming tutorial for beginnersC programming tutorial for beginners
C programming tutorial for beginners
 
01 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_0101 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_01
 
Escape sequence in c part 1
Escape sequence in c   part 1Escape sequence in c   part 1
Escape sequence in c part 1
 
C tutorial
C tutorialC tutorial
C tutorial
 
Li fi
Li fiLi fi
Li fi
 
SAP BI 7 security concepts
SAP BI 7 security conceptsSAP BI 7 security concepts
SAP BI 7 security concepts
 
CCNA Interview Questions and Answer ppt - JavaTpoint
CCNA Interview Questions and Answer ppt - JavaTpointCCNA Interview Questions and Answer ppt - JavaTpoint
CCNA Interview Questions and Answer ppt - JavaTpoint
 
BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5
BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5
BIOLOGY FORM 4 CHAPTER 8 - DYNAMIC ECOSYSTEM PART 5
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
Coordination & Response Part 1 - The Nervous System
Coordination & Response Part 1 - The Nervous SystemCoordination & Response Part 1 - The Nervous System
Coordination & Response Part 1 - The Nervous System
 
Wireless technology from 0G to 7.5G
Wireless technology from 0G to 7.5GWireless technology from 0G to 7.5G
Wireless technology from 0G to 7.5G
 
C++11
C++11C++11
C++11
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 

Similar to The C Language - An International Standard

Chapter 1: Introduction
Chapter 1: IntroductionChapter 1: Introduction
Chapter 1: IntroductionEric Chou
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptxSKUP1
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxSKUP ACADEMY
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxSKUP ACADEMY
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptxLECO9
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingMalikaJoya
 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programmingNico Ludwig
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET Dmytro Mindra
 
Chapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this pptChapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this pptANISHYAPIT
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageGOKULKANNANMMECLECTC
 

Similar to The C Language - An International Standard (20)

C session 1.pptx
C session 1.pptxC session 1.pptx
C session 1.pptx
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
Chapter 1: Introduction
Chapter 1: IntroductionChapter 1: Introduction
Chapter 1: Introduction
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
C som-programmeringssprog-bt
C som-programmeringssprog-btC som-programmeringssprog-bt
C som-programmeringssprog-bt
 
C programming
C programmingC programming
C programming
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptx
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptx
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptx
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptx
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programming
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Ch1 Introducing C
Ch1 Introducing CCh1 Introducing C
Ch1 Introducing C
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 
Chapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this pptChapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this ppt
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

The C Language - An International Standard

  • 1. The C Language An International Standard CIS2450 Professional Aspect of Software Engineering 1
  • 2. ANSI C • The C language appeared in the early 1970s and was originally cryptic, small, and tolerant. For the next ten years C evolved in the UNIX environment. • The resultant language was first described in the paper “Portability of C Programs and the UNIX System,” by S.C. Johnson and Dennis Ritchie in 1978. • This style of C was commonly called UNIX C. 2
  • 3. ANSI C • In 1989 the American National Standards Institute (ANSI) standardized C as standard X3.159-1989. • In December of that year the International Standards Organization ISO adopted the ANSI C standard making minor changes. • In 1990 ANSI then re-adopted ISO standard C. • This version of C is known as either ANSI C or Standard C. 3
  • 4. Implementation Characteristics • The ANSI standard defines several terms which describe the characteristics of an implementation. They are useful to describe what is and is not acceptable in the language. • Implementation defined code means that the compiler writer chooses what happens and has to document it. – Example: whether the sign bit is propagated when shifting a bit right. 4
  • 5. Implementation Characteristics • Unspecified behavior for something correct which the standard does not impose any requirements. – Example: the order of argument evaluation. • Undefined behavior is something incorrect which the standard does not impose any requirements. Anything may happen, from nothing, to a warning message, to program termination. – Example: what happens when a signed integer overflows. 5
  • 6. Implementation Characteristics • A constraint is a restriction or requirement which must be obeyed. If you do not then your program will become undefined. – Example: the operands of the % operator must be of integral type or a diagnostic will result. • An interesting problem with the definition of constraints is that compilers only have to produce an error message if a program violates both syntax and constraints. 6
  • 7. Implementation Characteristics • Semantic rules which are not explicitly stated can be broken and because this behavior is undefined the compiler does not have to issue a warning. – Example: the C standard header files have a function called malloc, but redefining this function is not a constraint so the compiler does not have to warn if this happens. 7
  • 8. Implementation Characteristics • Strictly conforming code is one which: – uses only specified features – doesn't exceed any implementation-defined limit – has no output that depends on implementation defined, unspecified, or undefined features • This is not a very interesting class because there are so few programs which meet the criteria. 8
  • 9. Implementation Characteristics • Conforming programs can depend on non- portable features. • A conforming program is considered with respect to a specific implementation and may be non-conforming using a different compiler. It can have extensions, but not ones which alter the behavior of a strictly conforming program. 9
  • 10. ANSI Changes to (older) C • A variety of minimum sizes were defined by the standard including: – 31 parameters in a function definition – 31 arguments in a function call – 509 characters in a source line – 32 levels of nested parentheses in an expression – long ints are at least 32 bits 10
  • 11. Differences between ANSI and K&R • Prototype change – parameters must be written in the function declaration, not just the definition. • Keyword changes – several new keywords were added including enum, const, volatile, signed, and void. 11
  • 12. Differences between ANSI and K&R • Quiet changes – which are mostly minor changes which cause code to still compile but perhaps operate in a different manner. • Everything else – these changes will have almost no effect and will almost never be encountered in practice, e.g. trigraphs can be used to represent a single character by using three characters, so ??< represents { 12
  • 13. New Features of C99 • Coding – end-of-line (//) comments like C++ – Mix declarations and code – Remove implicit function declaration • Data types – long long int (minimum 64bit Integer) – Variable length arrays – Flexible array members of structures • Library – snprintf family of functions in stdio.h 13
  • 14. Why Do We Care about Older C? • For new development, we don’t, but… • Huge installed code base is “old” – Many jobs involve maintenance of legacy code – Avoid misunderstanding legacy code • Based on your new-C habits – Avoid introducing bugs into legacy code • Keep to legacy coding style for consistency • Choices: retain older C compiler or try to upgrade to new compiler standard (exposes “code rot”) 14
  • 15. What is “code rot”? • Aka “software rot” “bit rot” • When program hasn’t been changed, yet stops working/compiling – Earlier assumptions no longer valid (e.g., famous Y2K bug → 2 bytes no longer enough) – Compiler, libraries, or operating system “upgraded,” features discontinued or incompatible 15
  • 16. Holding Code Rot at Bay • Recognize assumptions that won’t stand test of time – “Users will never need more than 32767 records, so 16- bit index is fine!” (+1 looks <0) → Comair fiasco • Write strictly-conforming software, not relying on extensions or “tricks” – E.g., intentionally accessing outside array bounds • Recompile when language spec revised, system upgraded, etc. – May discover small problems, easily fixed – Or BIG problems needing major reexamination 16