Rationale for International Standard— Programming Languages— C

Total Page:16

File Type:pdf, Size:1020Kb

Rationale for International Standard— Programming Languages— C Rationale for International Standard— Programming Languages— C Revision 5.10 April-2003 UNIX is a trademark of The Open Group. POSIX is a trademark of IEEE. Contents 0. Introduction ............................................................................................................................1 0.1 Organization of the document ......................................................................................5 1. Scope ......................................................................................................................................7 2. Normative References............................................................................................................9 5 3. Terms and definitions...........................................................................................................11 4. Conformance ........................................................................................................................13 5. Environment.........................................................................................................................15 5.1 Conceptual models......................................................................................................15 5.1.1 Translation environment.................................................................................15 10 5.1.2 Execution environments .................................................................................17 5.2 Environmental considerations....................................................................................19 5.2.1 Character sets..................................................................................................19 5.2.2 Character display semantics ...........................................................................23 5.2.3 Signals and interrupts.....................................................................................24 15 5.2.4 Environmental limits ......................................................................................24 6. Language ..............................................................................................................................31 6.2 Concepts .....................................................................................................................31 6.2.1 Scopes of identifiers .......................................................................................31 6.2.2 Linkages of identifiers ....................................................................................32 20 6.2.3 Name spaces of identifiers..............................................................................34 6.2.4 Storage durations of objects............................................................................34 6.2.5 Types...............................................................................................................36 6.2.6 Representations of types.................................................................................43 6.2.7 Compatible type and composite type..............................................................43 25 6.3 Conversions ................................................................................................................44 6.3.1 Arithmetic operands........................................................................................44 6.3.1.6 Complex types ................................................................................................46 6.3.1.7 Real and complex ...........................................................................................46 6.3.2 Other operands................................................................................................48 30 6.4 Lexical Elements ........................................................................................................49 6.4.1 Keywords........................................................................................................50 6.4.2 Identifiers........................................................................................................50 6.4.3 Universal character names..............................................................................51 6.4.4 Constants.........................................................................................................51 35 6.4.5 String literals...................................................................................................55 6.4.6 Punctuators .....................................................................................................57 6.4.7 Header names..................................................................................................57 6.4.8 Preprocessing numbers ...................................................................................57 6.4.9 Comments.......................................................................................................58 40 6.5 Expressions.................................................................................................................58 6.5.1 Primary expressions........................................................................................61 6.5.2 Postfix operators.............................................................................................61 6.5.3 Unary operators..............................................................................................64 6.5.4 Cast operators.................................................................................................66 ii Contents 6.5.5 Multiplicative operators..................................................................................67 6.5.6 Additive operators ..........................................................................................67 6.5.7 Bitwise shift operators ....................................................................................68 6.5.8 Relational operators........................................................................................69 5 6.5.9 Equality operators...........................................................................................69 6.5.15 Conditional operator .......................................................................................69 6.5.16 Assignment operators.....................................................................................69 6.5.17 Comma operator .............................................................................................71 6.6 Constant expressions..................................................................................................71 10 6.7 Declarations ................................................................................................................72 6.7.1 Storage-class specifiers...................................................................................72 6.7.2 Type specifiers................................................................................................72 6.7.3 Type qualifiers................................................................................................75 6.7.4 Function specifiers..........................................................................................80 15 6.7.5 Declarators......................................................................................................81 6.7.6 Type names.....................................................................................................87 6.7.7 Type definitions..............................................................................................87 6.7.8 Initialization....................................................................................................88 6.8 Statements and blocks.................................................................................................90 20 6.8.1 Labeled statements..........................................................................................91 6.8.2 Compound statement ......................................................................................92 6.8.3 Expression and null statements.......................................................................92 6.8.4 Selection statements........................................................................................92 6.8.5 Iteration statements.........................................................................................93 25 6.8.6. Jump statements..............................................................................................94 6.9 External definitions.....................................................................................................95 6.9.1 Function definitions........................................................................................95 6.9.2 External object definitions..............................................................................97 6.10 Preprocessing directives.............................................................................................97 30 6.10.1 Conditional inclusion......................................................................................97 6.10.2 Source file inclusion.......................................................................................98 6.10.3 Macro replacement .........................................................................................99 6.10.4 Line control...................................................................................................105 6.10.5 Error directive...............................................................................................105
Recommended publications
  • The Origin of the Peculiarities of the Vietnamese Alphabet André-Georges Haudricourt
    The origin of the peculiarities of the Vietnamese alphabet André-Georges Haudricourt To cite this version: André-Georges Haudricourt. The origin of the peculiarities of the Vietnamese alphabet. Mon-Khmer Studies, 2010, 39, pp.89-104. halshs-00918824v2 HAL Id: halshs-00918824 https://halshs.archives-ouvertes.fr/halshs-00918824v2 Submitted on 17 Dec 2013 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Published in Mon-Khmer Studies 39. 89–104 (2010). The origin of the peculiarities of the Vietnamese alphabet by André-Georges Haudricourt Translated by Alexis Michaud, LACITO-CNRS, France Originally published as: L’origine des particularités de l’alphabet vietnamien, Dân Việt Nam 3:61-68, 1949. Translator’s foreword André-Georges Haudricourt’s contribution to Southeast Asian studies is internationally acknowledged, witness the Haudricourt Festschrift (Suriya, Thomas and Suwilai 1985). However, many of Haudricourt’s works are not yet available to the English-reading public. A volume of the most important papers by André-Georges Haudricourt, translated by an international team of specialists, is currently in preparation. Its aim is to share with the English- speaking academic community Haudricourt’s seminal publications, many of which address issues in Southeast Asian languages, linguistics and social anthropology.
    [Show full text]
  • Bounds Checking on GPU
    Noname manuscript No. (will be inserted by the editor) Bounds Checking on GPU Troels Henriksen Received: date / Accepted: date Abstract We present a simple compilation strategy for safety-checking array indexing in high-level languages on GPUs. Our technique does not depend on hardware support for abnormal termination, and is designed to be efficient in the non-failing case. We rely on certain properties of array languages, namely the absence of arbitrary cross-thread communication, to ensure well-defined execution in the presence of failures. We have implemented our technique in the compiler for the functional array language Futhark, and an empirical eval- uation on 19 benchmarks shows that the geometric mean overhead of checking array indexes is respectively 4% and 6% on two different GPUs. Keywords GPU · functional programming · compilers 1 Introduction Programming languages can be divided roughly into two categories: unsafe languages, where programming errors can lead to unpredictable results at run- time; and safe languages, where all risky operations are guarded by run-time checks. Consider array indexing, where an invalid index will lead an unsafe lan- guage to read from an invalid memory address. At best, the operating system will stop the program, but at worst, the program will silently produce invalid results. A safe language will perform bounds checking to verify that the array index is within the bounds of the array, and if not, signal that something is amiss. Some languages perform an abnormal termination of the program and print an error message pointing to the offending program statement. Other languages throw an exception, allowing the problem to be handled by the pro- gram itself.
    [Show full text]
  • 1 Curl and Divergence
    Sections 15.5-15.8: Divergence, Curl, Surface Integrals, Stokes' and Divergence Theorems Reeve Garrett 1 Curl and Divergence Definition 1.1 Let F = hf; g; hi be a differentiable vector field defined on a region D of R3. Then, the divergence of F on D is @ @ @ div F := r · F = ; ; · hf; g; hi = f + g + h ; @x @y @z x y z @ @ @ where r = h @x ; @y ; @z i is the del operator. If div F = 0, we say that F is source free. Note that these definitions (divergence and source free) completely agrees with their 2D analogues in 15.4. Theorem 1.2 Suppose that F is a radial vector field, i.e. if r = hx; y; zi, then for some real number p, r hx;y;zi 3−p F = jrjp = (x2+y2+z2)p=2 , then div F = jrjp . Theorem 1.3 Let F = hf; g; hi be a differentiable vector field defined on a region D of R3. Then, the curl of F on D is curl F := r × F = hhy − gz; fz − hx; gx − fyi: If curl F = 0, then we say F is irrotational. Note that gx − fy is the 2D curl as defined in section 15.4. Therefore, if we fix a point (a; b; c), [gx − fy](a; b; c), measures the rotation of F at the point (a; b; c) in the plane z = c. Similarly, [hy − gz](a; b; c) measures the rotation of F in the plane x = a at (a; b; c), and [fz − hx](a; b; c) measures the rotation of F in the plane y = b at the point (a; b; c).
    [Show full text]
  • So Many Date Formats: Which Should You Use? Kamlesh Patel, Jigar Patel, Dilip Patel, Vaishali Patel Rang Technologies Inc, Piscataway, NJ
    Paper – 2463-2017 So Many Date Formats: Which Should You Use? Kamlesh Patel, Jigar Patel, Dilip Patel, Vaishali Patel Rang Technologies Inc, Piscataway, NJ ABSTRACT Nearly all data is associated with some Date information. In many industries, a SAS® programmer comes across various Date formats in data that can be of numeric or character type. An industry like pharmaceuticals requires that dates be shown in ISO 8601 formats due to industry standards. Many SAS programmers commonly use a limited number of Date formats (like YYMMDD10. or DATE9.) with workarounds using scans or substring SAS functions to process date-related data. Another challenge for a programmer can be the source data, which can include either Date-Time or only Date information. How should a programmer convert these dates to the target format? There are many existing Date formats (like E8601 series, B8601 series, and so on) and informants available to convert the source Date to the required Date efficiently. In addition, there are some useful functions that we can explore for deriving timing-related variables. For these methods to be effective, one can use simple tricks to remember those formats. This poster is targeted to those who have a basic understanding of SAS dates. KEYWORDS SAS, date, time, Date-Time, format, informat, ISO 8601, tips, Basic, Extended, Notation APPLICATIONS: SAS v9.2 INTRODUCTION Date and time concept in SAS is very interesting and can be handled very efficiently if SAS programmers know beyond basics of different SAS Date formats and informats along with many different Date functions. There are various formats available to use as per need in SAS.
    [Show full text]
  • TASKING VX-Toolset for Tricore User Guide
    TASKING VX-toolset for TriCore User Guide MA160-800 (v6.1) September 14, 2016 Copyright © 2016 Altium Limited. All rights reserved.You are permitted to print this document provided that (1) the use of such is for personal use only and will not be copied or posted on any network computer or broadcast in any media, and (2) no modifications of the document is made. Unauthorized duplication, in whole or part, of this document by any means, mechanical or electronic, including translation into another language, except for brief excerpts in published reviews, is prohibited without the express written permission of Altium Limited. Unauthorized duplication of this work may also be prohibited by local statute. Violators may be subject to both criminal and civil penalties, including fines and/or imprisonment. Altium®, TASKING®, and their respective logos are registered trademarks of Altium Limited or its subsidiaries. All other registered or unregistered trademarks referenced herein are the property of their respective owners and no trademark rights to the same are claimed. Table of Contents 1. C Language .................................................................................................................. 1 1.1. Data Types ......................................................................................................... 1 1.1.1. Half Precision Floating-Point ....................................................................... 3 1.1.2. Fractional Types .......................................................................................
    [Show full text]
  • Operating Systems and Applications for Embedded Systems >>> Toolchains
    >>> Operating Systems And Applications For Embedded Systems >>> Toolchains Name: Mariusz Naumowicz Date: 31 sierpnia 2018 [~]$ _ [1/19] >>> Plan 1. Toolchain Toolchain Main component of GNU toolchain C library Finding a toolchain 2. crosstool-NG crosstool-NG Installing Anatomy of a toolchain Information about cross-compiler Configruation Most interesting features Sysroot Other tools POSIX functions AP [~]$ _ [2/19] >>> Toolchain A toolchain is the set of tools that compiles source code into executables that can run on your target device, and includes a compiler, a linker, and run-time libraries. [1. Toolchain]$ _ [3/19] >>> Main component of GNU toolchain * Binutils: A set of binary utilities including the assembler, and the linker, ld. It is available at http://www.gnu.org/software/binutils/. * GNU Compiler Collection (GCC): These are the compilers for C and other languages which, depending on the version of GCC, include C++, Objective-C, Objective-C++, Java, Fortran, Ada, and Go. They all use a common back-end which produces assembler code which is fed to the GNU assembler. It is available at http://gcc.gnu.org/. * C library: A standardized API based on the POSIX specification which is the principle interface to the operating system kernel from applications. There are several C libraries to consider, see the following section. [1. Toolchain]$ _ [4/19] >>> C library * glibc: Available at http://www.gnu.org/software/libc. It is the standard GNU C library. It is big and, until recently, not very configurable, but it is the most complete implementation of the POSIX API. * eglibc: Available at http://www.eglibc.org/home.
    [Show full text]
  • Truffle/C Interpreter
    JOHANNES KEPLER UNIVERSITAT¨ LINZ JKU Faculty of Engineering and Natural Sciences Truffle/C Interpreter Master’s Thesis submitted in partial fulfillment of the requirements for the academic degree Diplom-Ingenieur in the Master’s Program Computer Science Submitted by Manuel Rigger, BSc. At the Institut f¨urSystemsoftware Advisor o.Univ.-Prof. Dipl.-Ing. Dr.Dr.h.c. Hanspeter M¨ossenb¨ock Co-advisor Dipl.-Ing. Lukas Stadler Dipl.-Ing. Dr. Thomas W¨urthinger Xiamen, April 2014 Contents I Contents 1 Introduction 3 1.1 Motivation . .3 1.2 Goals and Scope . .4 1.3 From C to Java . .4 1.4 Structure of the Thesis . .6 2 State of the Art 9 2.1 Graal . .9 2.2 Truffle . 10 2.2.1 Rewriting and Specialization . 10 2.2.2 Truffle DSL . 11 2.2.3 Control Flow . 12 2.2.4 Profiling and Inlining . 12 2.2.5 Partial Evaluation and Compilation . 12 2.3 Clang . 13 3 Architecture 14 3.1 From Clang to Java . 15 3.2 Node Construction . 16 3.3 Runtime . 16 4 The Truffle/C File 17 4.1 Truffle/C File Format Goals . 17 4.2 Truffle/C File Format 1 . 19 4.2.1 Constant Pool . 19 4.2.2 Function Table . 20 4.2.3 Functions and Attributes . 20 4.3 Truffle/C File Considerations and Comparison . 21 4.3.1 Java Class File and Truffle/C File . 21 4.3.2 ELF and Truffle/C File . 22 4.4 Clang Modification Truffle/C File . 23 Contents II 5 Truffle/C Data Types 25 5.1 Data Type Hierarchy: Boxing, Upcasts and Downcasts .
    [Show full text]
  • A Trusted Mechanised Javascript Specification
    A Trusted Mechanised JavaScript Specification Martin Bodin Arthur Charguéraud Daniele Filaretti Inria & ENS Lyon Inria & LRI, Université Paris Sud, CNRS Imperial College London [email protected] [email protected] d.fi[email protected] Philippa Gardner Sergio Maffeis Daiva Naudžiunien¯ e˙ Imperial College London Imperial College London Imperial College London [email protected] sergio.maff[email protected] [email protected] Alan Schmitt Gareth Smith Inria Imperial College London [email protected] [email protected] Abstract sation was crucial. Client code that works on some of the main JavaScript is the most widely used web language for client-side ap- browsers, and not others, is not useful. The first official standard plications. Whilst the development of JavaScript was initially just appeared in 1997. Now we have ECMAScript 3 (ES3, 1999) and led by implementation, there is now increasing momentum behind ECMAScript 5 (ES5, 2009), supported by all browsers. There is the ECMA standardisation process. The time is ripe for a formal, increasing momentum behind the ECMA standardisation process, mechanised specification of JavaScript, to clarify ambiguities in the with plans for ES6 and 7 well under way. ECMA standards, to serve as a trusted reference for high-level lan- JavaScript is the only language supported natively by all major guage compilation and JavaScript implementations, and to provide web browsers. Programs written for the browser are either writ- a platform for high-assurance proofs of language properties. ten directly in JavaScript, or in other languages which compile to We present JSCert, a formalisation of the current ECMA stan- JavaScript.
    [Show full text]
  • ASN.1. Communication Between Heterogeneous Systems – Errata
    ASN.1. Communication between heterogeneous systems – Errata These errata concern the June 5, 2000 electronic version of the book "ASN.1. Communication between heterogeneous systems", by Olivier Dubuisson (© 2000). (freely available at http://www.oss.com/asn1/resources/books‐whitepapers‐pubs/asn1‐ books.html#dubuisson.) N.B.: The first page number refers to the PDF electronic copy and is the number printed on each page, not the number at the bottom of the Acrobat Reader window. The page number in parentheses refers to the paper copy published by Morgan Kaufmann. Page 9 (page 8 for the paper copy): ‐ last line, replace "(the number 0 low‐weighted byte" with "(the number 0 low‐weighted bit". Page 19 (page 19 for the paper copy): ‐ on the paper copy, second bullet, replace "the Physical Layer marks up..." with "the Data Link Layer marks up...". ‐ on the electronic copy, second bullet, replace "it is down to the Physical Layer to mark up..." with "it is down to the Data Link Layer to mark up...". Page 25 (page 25 for the paper copy): second paragraph, replace "that all the data exchange" with "that all the data exchanged". Page 32 (page 32 for the paper copy): last paragraph, replace "The order number has at least 12 digits" with "The order number has always 12 digits". Page 34 (page 34 for the paper copy): first paragraph, replace "it will be computed again since..." with "it will be computed again because...". Page 37 for the electronic copy only: in the definition of Quantity, replace "unites" with "units". Page 104 (page 104 for the paper copy): ‐ in rule <34>, delete ", digits"; ‐ at the end of section 8.3.2, add the following paragraph: Symbols such as "{", "[", "[[", etc, are also lexical tokens of the ASN.1 notation.
    [Show full text]
  • Contents of Lecture 4: Declarations
    Contents of Lecture 4: Declarations Implicint int Storage class specifiers Type specifiers Enumeration specifiers Type qualifiers Jonas Skeppstedt ([email protected]) Lecture 4 2014 1 / 39 Now obsolete: implicit int Sometimes you can see code such as: main() // invalid { } or even: #include <stdio.h> count; // invalid float x; In earlier versions of C one could skip the type, which then became int, and is called implicit int. Calling a function before its declaration also set its return type to int. It’s invalid C so don’t use it — but compilers often allow it... Jonas Skeppstedt ([email protected]) Lecture 4 2014 2 / 39 Storage class specifiers Last lecture we discussed the different kinds of storage durations. Now we will see how to specify some of them explicitly. Dynamic (important) and temporary (less important) storage duration are not specified by the programmer using any particular syntax but defined by the standard. The storage class specifiers are: typedef extern static _Thread_local auto register Of these typedef does not refer to any kind of storage duration — instead it introduces another name of a type and not a new type: typedef int num_t; int* p; num_t* q; p = q; // valid since p and q have the same type. Jonas Skeppstedt ([email protected]) Lecture 4 2014 3 / 39 Storage class specifiers: static at file scope static int count; /∗ initialized to zero. ∗/ static void init(void) { /∗ Do some initializations ... ∗/ } Used to make an identifier invisible outside the source file With static at file scope, there is no risk of name conflicts with other files.
    [Show full text]
  • XL C/C++: Language Reference About This Document
    IBM XL C/C++ for Linux, V16.1.1 IBM Language Reference Version 16.1.1 SC27-8045-01 IBM XL C/C++ for Linux, V16.1.1 IBM Language Reference Version 16.1.1 SC27-8045-01 Note Before using this information and the product it supports, read the information in “Notices” on page 63. First edition This edition applies to IBM XL C/C++ for Linux, V16.1.1 (Program 5765-J13, 5725-C73) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. © Copyright IBM Corporation 1998, 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this document ......... v Chapter 4. IBM extension features ... 11 Who should read this document........ v IBM extension features for both C and C++.... 11 How to use this document.......... v General IBM extensions ......... 11 How this document is organized ....... v Extensions for GNU C compatibility ..... 15 Conventions .............. v Extensions for vector processing support ... 47 Related information ........... viii IBM extension features for C only ....... 56 Available help information ........ ix Extensions for GNU C compatibility ..... 56 Standards and specifications ........ x Extensions for vector processing support ... 58 Technical support ............ xi IBM extension features for C++ only ...... 59 How to send your comments ........ xi Extensions for C99 compatibility ...... 59 Extensions for C11 compatibility ...... 59 Chapter 1. Standards and specifications 1 Extensions for GNU C++ compatibility .... 60 Chapter 2. Language levels and Notices .............. 63 language extensions ......... 3 Trademarks .............
    [Show full text]
  • GNU MPFR the Multiple Precision Floating-Point Reliable Library Edition 4.1.0 July 2020
    GNU MPFR The Multiple Precision Floating-Point Reliable Library Edition 4.1.0 July 2020 The MPFR team [email protected] This manual documents how to install and use the Multiple Precision Floating-Point Reliable Library, version 4.1.0. Copyright 1991, 1993-2020 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back- Cover Texts. A copy of the license is included in Appendix A [GNU Free Documentation License], page 59. i Table of Contents MPFR Copying Conditions ::::::::::::::::::::::::::::::::::::::: 1 1 Introduction to MPFR :::::::::::::::::::::::::::::::::::::::: 2 1.1 How to Use This Manual::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 2 2 Installing MPFR ::::::::::::::::::::::::::::::::::::::::::::::: 3 2.1 How to Install ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 3 2.2 Other `make' Targets :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 2.3 Build Problems :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 2.4 Getting the Latest Version of MPFR ::::::::::::::::::::::::::::::::::::::::::::::: 4 3 Reporting Bugs::::::::::::::::::::::::::::::::::::::::::::::::: 5 4 MPFR Basics ::::::::::::::::::::::::::::::::::::::::::::::::::: 6 4.1 Headers and Libraries :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 6
    [Show full text]