Deutsch   English   Français   Italiano  
<vppvb6$35gb9$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Ar Rakin <rakinar2@onesoftnet.eu.org>
Newsgroups: comp.lang.c
Subject: Re: Which code style do you prefer the most?
Date: Thu, 27 Feb 2025 21:11:33 +0600
Organization: OSN Developers
Lines: 78
Message-ID: <vppvb6$35gb9$1@dont-email.me>
References: <vpkmq0$21php$1@dont-email.me> <vplhc7$26ur1$3@dont-email.me>
 <87v7swzzl7.fsf@onesoftnet.eu.org> <vpn4qi$2j0hq$1@dont-email.me>
 <vpo20n$2o9ks$1@dont-email.me> <vpo7ec$2ovro$1@dont-email.me>
 <87a5a7k0ko.fsf@onesoftnet.eu.org> <vpps7v$34tq7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 27 Feb 2025 16:11:34 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c3cc10b9b7308b1f47db985a421ccf9c";
	logging-data="3326313"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19MSbDHLnNlA7LE3tYq2inF0fbLESfSwoY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:g8wBeCvOM5zRODnGmRcU4L+M6Og=
In-Reply-To: <vpps7v$34tq7$1@dont-email.me>
Content-Language: en-US
Bytes: 3464

On 2/27/25 8:18 PM, bart wrote:
> On 27/02/2025 12:56, Ar Rakin wrote:
>> bart <bc@freeuk.com> writes:
>>
>>> // isn't devoid of quirks (this is still C after all), for example:
>>>
>>>     fopen(file,"rb");   // open file in \windows\system32\
>>>     fread(...);
>>>
>>> Here, the // line continues onto the next, so that the fread is
>>> commented out. But they are fewer.
>>
>> Interesting. Isn't this considered a compiler bug?
> 
> It's to do with how C is defined, which requires that its implementation 
> corresponds to series of phases.
> 
> Then line-splicing, which combines two lines if the first ends with \, 
> is done before processing // comments.
> 
>   I am aware that you
>> can do the same thing with strings like this:
>>
>> fprintf(stderr, "multi\
>> line\
>> strings\
>> are fun.");
>>
>> I can understand how this might be useful; but with *comments*?? Was
>> that actually a thing in the official C standards?
> 
> It's isn't that useful for strings; the following is simpler and also 
> works:
> 
>    "multi"
>    "line"
>    "string"
> 
> But it is needed for multi-line macros, as C's proprocessor is strictly 
> line-oriented and a macro definition must fit onto one line.
> 
> So lines spliced with \ can be used to combine multiple lines into one. 
> A side-effect is that you can't use // comments for individual lines of 
> a multi-line macro, it would screw things up.
> 
>> To me it just feels like a compiler bug that was never fixed.
> 
> To me the whole of C feels like one huge language bug!
> 
> The way line splicing works has even weirder repercussions; any token 
> can be split across lines:
> 
> i\
> n\
> t abc;      // split 'int' across 3 lines
> 
> /\
> / This is a '//' comment with // split across two lines
> 
> /\
> * This is a /* ... comment */
> 
> "ABC\\
> nDEF"      // A split string escape code
> 
> if (a =\
> = b) ...
> 
> In fact, any C source file can be written with one character per line, 
> plus the \ line continuation.
> 
> 

This is so weird LMAO, good to know though.  But still, I will continue 
to love C and will still write more C code :-)

-- 
Rakin