On 14/01/2024 05:34, Sandra Loosemore wrote:
> On 1/10/24 14:28, Jonny Grant wrote:
>>
>> 2024-01-10 Jonathan Grant <j...@jguk.org>
>> gcc/ChangeLog:
>> * doc/extend.texi: Update builtin example for __builtin_FILE
>> __builtin_LINE __builtin_FUNCTION.
>>
>>
>>
>>>From 66290eb477dd1a99310ad9972c45391c2a87c1c7 Mon Sep 17 00:00:00 2001
>> From: Jonathan Grant <j...@jguk.org>
>> Date: Wed, 29 Nov 2023 11:02:06 +0000
>> Subject: [PATCH] gcc/doc: Update builtin example for __builtin_FILE
>> __builtin_LINE __builtin_FUNCTION
>>
>>
>> Signed-off-by: Jonathan Grant <j...@jguk.org>
>> ---
>> gcc/doc/extend.texi | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
>> index 1ae589aeb29..f17a4b215de 100644
>> --- a/gcc/doc/extend.texi
>> +++ b/gcc/doc/extend.texi
>> @@ -14660,20 +14660,22 @@ to @var{F} or the empty string if the call was not
>> made at function
>> scope.
>>
>> For example, in the following, each call to function @code{foo} will
>> -print a line similar to @code{"file.c:123: foo: message"} with the name
>> +print a line similar to @code{"file.c:5: foo: message"} with the name
>
> Please also s/will print/prints/
>
>> of the file and the line number of the @code{printf} call, the name of
>> the function @code{foo}, followed by the word @code{message}.
>>
>> @smallexample
>> -const char*
>> -function (const char *func = __builtin_FUNCTION ())
>> +#include <stdio.h>
>> +
>> +void foo (void)
>> @{
>> - return func;
>> + printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (),
>> __builtin_FUNCTION ());
>> + printf ("%s:%i: %s: message\n", __builtin_FILE (), __builtin_LINE (), );
>
> Is this duplicated code a mistake? As you have it, each call to foo prints
> *two* lines, not "a line". Maybe you mean to have more than one call to foo
> instead of more than one line printed per call? If it's intentional, please
> correct the above descriptive text.
Thank you for the review comments Sandra.
The duplicate lines were my mistake.
> Also, I'm pretty sure this line of code is too long to format nicely in the
> PDF manual (it's well over 80 characters). I'd put a line break after the
> call to __builtin_FILE ().
yes, that's good. If the __builtin_LINE () is on the next line, unfortunately
line number won't be the same as the printf line. But I did move the
__builtin_FUNCTION () so it's under 80, is that okay?
Will a v3 version of the patch with a few other changes. Let me know what you
think.
Thanks, Jonny