Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
ccd96f0a
Commit
ccd96f0a
authored
Jan 13, 2001
by
Neil Booth
Committed by
Neil Booth
Jan 13, 2001
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* extend.texi: Update for CPP.
From-SVN: r38986
parent
174fa2c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
41 deletions
+81
-41
gcc/ChangeLog
+4
-0
gcc/extend.texi
+77
-41
No files found.
gcc/ChangeLog
View file @
ccd96f0a
2001-01-13 Neil Booth <neil@daikokuya.demon.co.uk>
* extend.texi: Udate for CPP.
2001-01-13 Andreas Jaeger <aj@suse.de>
2001-01-13 Andreas Jaeger <aj@suse.de>
* reload1.c: Add prototype for replace_pseudos_in_call_usage.
* reload1.c: Add prototype for replace_pseudos_in_call_usage.
...
...
gcc/extend.texi
View file @
ccd96f0a
...
@@ -43,7 +43,9 @@ C++ Language}, for extensions that apply @emph{only} to C++.
...
@@ -43,7 +43,9 @@ C++ Language}, for extensions that apply @emph{only} to C++.
*
Hex
Floats
::
Hexadecimal
floating
-
point
constants
.
*
Hex
Floats
::
Hexadecimal
floating
-
point
constants
.
*
Zero
Length
::
Zero
-
length
arrays
.
*
Zero
Length
::
Zero
-
length
arrays
.
*
Variable
Length
::
Arrays
whose
length
is
computed
at
run
time
.
*
Variable
Length
::
Arrays
whose
length
is
computed
at
run
time
.
*
Macro
Varargs
::
Macros
with
variable
number
of
arguments
.
*
Variadic
Macros
::
Macros
with
a
variable
number
of
arguments
.
*
Escaped
Newlines
::
Slightly
looser
rules
for
escaped
newlines
.
*
Multi
-
line
Strings
::
String
literals
with
embedded
newlines
.
*
Subscripting
::
Any
array
can
be
subscripted
,
even
if
not
an
lvalue
.
*
Subscripting
::
Any
array
can
be
subscripted
,
even
if
not
an
lvalue
.
*
Pointer
Arith
::
Arithmetic
on
@
code
{
void
}-
pointers
and
function
pointers
.
*
Pointer
Arith
::
Arithmetic
on
@
code
{
void
}-
pointers
and
function
pointers
.
*
Initializers
::
Non
-
constant
initializers
.
*
Initializers
::
Non
-
constant
initializers
.
...
@@ -90,7 +92,9 @@ C++ Language}, for extensions that apply @emph{only} to C++.
...
@@ -90,7 +92,9 @@ C++ Language}, for extensions that apply @emph{only} to C++.
* Hex Floats:: Hexadecimal floating-point constants.
* Hex Floats:: Hexadecimal floating-point constants.
* Zero Length:: Zero-length arrays.
* Zero Length:: Zero-length arrays.
* Variable Length:: Arrays whose length is computed at run time.
* Variable Length:: Arrays whose length is computed at run time.
* Macro Varargs:: Macros with variable number of arguments.
* Variadic Macros:: Macros with a variable number of arguments.
* Escaped Newlines:: Slightly looser rules for escaped newlines.
* Multi-line Strings:: String literals with embedded newlines.
* Subscripting:: Any array can be subscripted, even if not an lvalue.
* Subscripting:: Any array can be subscripted, even if not an lvalue.
* Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
* Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
* Initializers:: Non-constant initializers.
* Initializers:: Non-constant initializers.
...
@@ -1036,66 +1040,98 @@ last one must end with a semicolon, which is followed by the ``real''
...
@@ -1036,66 +1040,98 @@ last one must end with a semicolon, which is followed by the ``real''
parameter declarations. Each forward declaration must match a ``real''
parameter declarations. Each forward declaration must match a ``real''
declaration in parameter name and data type.
declaration in parameter name and data type.
@node
Macro Vararg
s
@node
Variadic Macro
s
@section Macros with
Variable Numbers of Arguments
@section Macros with
a Variable Number of Arguments.
@cindex variable number of arguments
@cindex variable number of arguments
@cindex macro with variable arguments
@cindex macro with variable arguments
@cindex rest argument (in macro)
@cindex rest argument (in macro)
@cindex variadic macros
In GNU C, a macro can accept a variable number of arguments, much as a
In the ISO C standard of 1999, a macro can be declared to accept a
function can. The syntax for defining the macro looks much like that
variable number of arguments much as a function can. The syntax for
used for a function. Here is an example:
defining the macro is similar to that of a function. Here is an
example:
@example
@example
#define eprintf(format, args...) \
#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
fprintf (stderr, format , ## args)
@end example
@end example
Here @code{args} is a @dfn{rest argument}: it takes in zero or more
Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
arguments, as many as the call contains. All of them plus the commas
such a macro, it represents the zero or more tokens until the closing
between them form the value of @code{args}, which is substituted into
parenthesis that ends the invocation, including any commas. This set of
the macro body where @code{args} is used. Thus, we have this expansion:
tokens replaces the identifier @code{__VA_ARGS__} in the macro body
wherever it appears. See the CPP manual for more information.
GCC has long supported variadic macros, and used a different syntax that
allowed you to give a name to the variable arguments just like any other
argument. Here is an example:
@example
@example
eprintf ("%s:%d: ", input_file_name, line_number)
#define debug(format, args...) fprintf (stderr, format, args)
@expansion{}
fprintf (stderr, "%s:%d: " , input_file_name, line_number)
@end example
@end example
@noindent
This is in all ways equivalent to the ISO C example above, but arguably
Note that the comma after the string constant comes from the definition
more readable and descriptive.
of @code{eprintf}, whereas the last comma comes from the value of
@code{args}.
The reason for using @samp{##} is to handle the case when @code{args}
GNU CPP has two further variadic macro extensions, and permits them to
matches no arguments at all. In this case, @code{args} has an empty
be used with either of the above forms of macro definition.
value. In this case, the second comma in the definition becomes an
embarrassment: if it got through to the expansion of the macro, we would
In standard C, you are not allowed to leave the variable argument out
get something like this:
entirely; but you are allowed to pass an empty argument. For example,
this invocation is invalid in ISO C, because there is no comma after
the string:
@example
@example
fprintf (stderr, "success!\n" ,
)
debug ("A message"
)
@end example
@end example
@noindent
GNU CPP permits you to completely omit the variable arguments in this
which is invalid C syntax. @samp{##} gets rid of the comma, so we get
way. In the above examples, the compiler would complain, though since
the following instead:
the expansion of the macro still has the extra comma after the format
string.
To help solve this problem, CPP behaves specially for variable arguments
used with the token paste operator, @samp{##}. If instead you write
@example
@example
fprintf (stderr, "success!\n"
)
#define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__
)
@end example
@end example
This is a special feature of the GNU C preprocessor: @samp{##} before a
and if the variable arguments are omitted or empty, the @samp{##}
rest argument that is empty discards the preceding sequence of
operator causes the preprocessor to remove the comma before it. If you
non-whitespace characters from the macro definition. (If another macro
do provide some variable arguments in your macro invocation, GNU CPP
argument precedes, none of it is discarded.)
does not complain about the paste operation and instead places the
variable arguments after the comma. Just like any other pasted macro
It might be better to discard the last preprocessor token instead of the
argument, these arguments are not macro expanded.
last preceding sequence of non-whitespace characters; in fact, we may
someday change this feature to do so. We advise you to write the macro
@node Escaped Newlines
definition so that the preceding sequence of non-whitespace characters
@section Slightly Looser Rules for Escaped Newlines
is just a single token, so that the meaning will not change if we change
@cindex escaped newlines
the definition of this feature.
@cindex newlines (escaped)
Recently, the non-traditional preprocessor has relaxed its treatment of
escaped newlines. Previously, the newline had to immediately follow a
backslash. The current implementation allows whitespace in the form of
spaces, horizontal and vertical tabs, and form feeds between the
backslash and the subsequent newline. The preprocessor issues a
warning, but treats it as a valid escaped newline and combines the two
lines to form a single logical line. This works within comments and
tokens, including multi-line strings, as well as between tokens.
Comments are @emph{not} treated as whitespace for the purposes of this
relaxation, since they have not yet been replaced with spaces.
@node Multi-line Strings
@section String Literals with Embedded Newlines
@cindex multi-line string literals
As an extension, GNU CPP permits string literals to cross multiple lines
without escaping the embedded newlines. Each embedded newline is
replaced with a single @samp{\n} character in the resulting string
literal, regardless of what form the newline took originally.
CPP currently allows such strings in directives as well (other than the
@samp{#include} family). This is deprecated and will eventually be
removed.
@node Subscripting
@node Subscripting
@section Non-Lvalue Arrays May Have Subscripts
@section Non-Lvalue Arrays May Have Subscripts
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment