Deutsch   English   Français   Italiano  
<vsofu3$3b14s$1@dont-email.me>

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

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: "A diagram of C23 basic types"
Date: Fri, 4 Apr 2025 13:31:15 +0200
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <vsofu3$3b14s$1@dont-email.me>
References: <87y0wjaysg.fsf@gmail.com> <vsj1m8$1f8h2$1@dont-email.me>
 <vsj2l9$1j0as$1@dont-email.me> <vsjef3$1u4nk$1@dont-email.me>
 <vsjg6t$20pdb$1@dont-email.me> <vsjjd1$23ukt$1@dont-email.me>
 <vsjkvb$25mtg$1@dont-email.me> <vsjlkq$230a5$2@dont-email.me>
 <20250402232443.00003a7d@yahoo.com> <vslilm$8mfb$1@dont-email.me>
 <vsm05b$k0b7$1@dont-email.me> <20250403164437.00002c5a@yahoo.com>
 <vsm7p1$t7nv$1@dont-email.me> <6NxHP.363009$l0_4.293847@fx43.iad>
 <vsmaro$10v9o$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 04 Apr 2025 13:31:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c769e35c057c19c3049ecfc31d4accc3";
	logging-data="3507356"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/WREv4bwGg6cHAGTBoBk+NePRwQewZ1qI="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:nb9JpJK2p7GRfhd4BGjHmQdJ6Ro=
Content-Language: en-GB
In-Reply-To: <vsmaro$10v9o$1@dont-email.me>

On 03/04/2025 17:52, bart wrote:
> On 03/04/2025 16:26, Scott Lurndal wrote:
>> bart <bc@freeuk.com> writes:
>>> On 03/04/2025 14:44, Michael S wrote:
>>
>>>> Overhead is a smaller concern. Name clashes are bigger concern.
>>>
>>> Examples? Somebody would be foolhardy to use names like 'printf' or
>>> 'exit' for their own, unrelated functions. (Compilers will anyway warn
>>> about that.)
>>
>> I've written my own printf and exit implementations in the
>> past.   Not all C code has a runtime that provides those name.
> 
> Then you have to specify, somehow, that you don't want those 
> automatically included.
> 

It is not unusual in embedded systems to provide your own versions of 
standard library functions.  For example, I have regularly implemented 
my own "exit" as something like :

	_Noreturn void exit(int status) {
		(void) status;
		while (true) ;
	}

I do that because in my embedded systems, the program never ends - but 
the C startup code typically calls exit() after main() returns.  This 
pulls in exit() from the library, which pulls in everything for handling 
at_exit() functions, which pulls in malloc(), and so on - for small 
microcontrollers, you can sometimes end up with a significant fraction 
of your flash used by library code you never want to use.

Similarly, sometimes you might want to replace standard library IO 
functions with something appropriate for the small devices.

This is all undefined behaviour in the C standards (mostly UB because it 
is not discussed or defined), but the way linkers work and the way most 
C standard libraries are arranged means it works fine.

However, it's a bit more questionable if you are making your own 
functions with names that coincide with standard library function names 
but have different signatures.