Assume C99 or later.
[bpt/emacs.git] / doc / lispref / internals.texi
index 759ed8c..3a5bd4a 100644 (file)
@@ -15,6 +15,7 @@ internal aspects of GNU Emacs that may be of interest to C programmers.
 * Pure Storage::        Kludge to make preloaded Lisp functions shareable.
 * Garbage Collection::  Reclaiming space for Lisp objects no longer used.
 * Memory Usage::        Info about total size of Lisp objects made so far.
+* C Dialect::           What C variant Emacs is written in.
 * Writing Emacs Primitives::   Writing C code for Emacs.
 * Object Internals::    Data formats of buffers, windows, processes.
 * C Integer Types::     How C integer types are used inside Emacs.
@@ -111,6 +112,8 @@ drawback that the documentation strings take up space in Emacs all the
 time.)
 @end itemize
 
+@cindex change @code{load-path} at configure time
+@cindex @option{--enable-locallisppath} option to @command{configure}
   It is not advisable to put anything in @file{site-load.el} or
 @file{site-init.el} that would alter any of the features that users
 expect in an ordinary unmodified Emacs.  If you feel you must override
@@ -517,8 +520,8 @@ done so far in this Emacs session.
 
 @defvar gc-elapsed
 This variable contains the total number of seconds of elapsed time
-during garbage collection so far in this Emacs session, as a floating
-point number.
+during garbage collection so far in this Emacs session, as a
+floating-point number.
 @end defvar
 
 @node Memory Usage
@@ -573,6 +576,19 @@ The total number of strings that have been allocated so far in this
 Emacs session.
 @end defvar
 
+@node C Dialect
+@section C Dialect
+@cindex C programming language
+
+The C part of Emacs is portable to C99 or later: C11-specific features such
+as @samp{<stdalign.h>} and @samp{_Noreturn} are not used without a check,
+typically at configuration time, and the Emacs build procedure
+provides a substitute implementation if necessary.  Some C11 features,
+such as anonymous structures and unions, are too difficult to emulate,
+so they are avoided entirely.
+
+At some point in the future the base C dialect will no doubt change to C11.
+
 @node Writing Emacs Primitives
 @section Writing Emacs Primitives
 @cindex primitive function internals
@@ -917,7 +933,7 @@ following basic data types: integer, symbol, string, cons cell, float,
 vectorlike or miscellaneous object.  Each of these data types has the
 corresponding tag value.  All tags are enumerated by @code{enum Lisp_Type}
 and placed into a 3-bit bitfield of the @code{Lisp_Object}.  The rest of the
-bits is the value itself.  Integer values are immediate, i.e., directly
+bits is the value itself.  Integers are immediate, i.e., directly
 represented by those @dfn{value bits}, and all other objects are represented
 by the C pointers to a corresponding object allocated from the heap.  Width
 of the @code{Lisp_Object} is platform- and configuration-dependent: usually
@@ -945,7 +961,7 @@ Array, a fixed-size set of Lisp objects which may be accessed by an index.
 Symbol, the unique-named entity commonly used as an identifier.
 
 @item struct Lisp_Float
-Floating point value.
+Floating-point value.
 
 @item union Lisp_Misc
 Miscellaneous kinds of objects which don't fit into any of the above.
@@ -1439,11 +1455,6 @@ The position in the buffer for which the line number is known, or
 @code{nil} meaning none is known.  If it is a buffer, don't display
 the line number as long as the window shows that buffer.
 
-@item region_showing
-If the region (or part of it) is highlighted in this window, this field
-holds the mark position that made one end of that region.  Otherwise,
-this field is @code{nil}.
-
 @item column_number_displayed
 The column number currently displayed in this window's mode line, or @code{nil}
 if column numbers are not being displayed.
@@ -1611,7 +1622,7 @@ although @code{off_t} is always signed, @code{time_t} need not be.
 
 @item
 Prefer the Emacs-defined type @code{printmax_t} for representing
-values that might be any signed integer value that can be printed,
+values that might be any signed integer that can be printed,
 using a @code{printf}-family function.
 
 @item
@@ -1619,20 +1630,22 @@ Prefer @code{intmax_t} for representing values that might be any
 signed integer value.
 
 @item
-In bitfields, prefer @code{unsigned int} or @code{signed int} to
-@code{int}, as @code{int} is less portable: it might be signed, and
-might not be.  Single-bit bit fields are invariably @code{unsigned
-int} so that their values are 0 and 1.
-
-@item
-In C, Emacs commonly uses @code{bool}, 1, and 0 for boolean values.
-Using @code{bool} for booleans can make programs easier to read and a
-bit faster than using @code{int}.  Although it is also OK to use
-@code{int}, this older style is gradually being phased out.  When
+Prefer @code{bool}, @code{false} and @code{true} for booleans.
+Using @code{bool} can make programs easier to read and a bit faster than
+using @code{int}.  Although it is also OK to use @code{int}, @code{0}
+and @code{1}, this older style is gradually being phased out.  When
 using @code{bool}, respect the limitations of the replacement
 implementation of @code{bool}, as documented in the source file
 @file{lib/stdbool.in.h}, so that Emacs remains portable to pre-C99
-platforms.
+platforms.  In particular, boolean bitfields should be of type
+@code{bool_bf}, not @code{bool}, so that they work correctly even when
+compiling Objective C with standard GCC.
+
+@item
+In bitfields, prefer @code{unsigned int} or @code{signed int} to
+@code{int}, as @code{int} is less portable: it might be signed, and
+might not be.  Single-bit bit fields should be @code{unsigned int} or
+@code{bool_bf} so that their values are 0 or 1.
 @end itemize
 
 @c FIXME Mention src/globals.h somewhere in this file?