Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Preprocessor Overheads Date: Fri, 03 Feb 2017 18:34:33 -0800 Organization: None to speak of Lines: 42 Message-ID: References: <6f4a3c6f-a81e-4b75-9be6-67e07f6584af@googlegroups.com> <7e401214-44c8-4003-850c-857c3e2b8c03@googlegroups.com> <846577bb-c24e-43bc-89b3-3028b9007355@googlegroups.com> <9d311cd1-7437-49cb-b308-f9ba2dff4808@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="70b944d02c574e6a9bb8f45ae4c7cdf9"; logging-data="23761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187Tw59MP/EciCHXEyPP+TS" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:BhXbMBvKq8yEhlVgHFVpKudxr28= sha1:dw8yZmCZo6NB29T9h6TbWfd5nMI= Xref: csiph.com comp.lang.c:103115 supercat@casperkitty.com writes: > On Friday, February 3, 2017 at 4:47:28 PM UTC-6, Richard Heathfield wrote: >> On 03/02/17 22:16, supercat wrote: >> > On Friday, February 3, 2017 at 2:51:49 PM UTC-6, Richard Heathfield wrote: >> >> On 03/02/17 20:23, supercat wrote: >> >>> The qsort() function accepts an argument of type "void*". If the >> >>> purpose of void* were as you say, that would imply that if I take >> >>> the address of the first element of a "struct foo[]", convert it >> >>> to void* and pass that to qsort(), the function would need to >> >>> somehow convert the pointer back to a "struct foo*" before it >> >>> could do anything else with it. >> >> >> >> No, it can pass it unmodified to another function (and in fact that's >> >> precisely what it /does/ do). >> > >> > Oh really? >> >> Yes. > > The supplied comparator function accepts two pointers of type void*. If > the qsort function merely passes the original pointer unmodified (rather > than, say, converting it to a char*, adding the offset to the desired > element, and then converting that back to a void*), how is the comparator > function supposed to know which parts of the array are supposed to be > compared? You're pointing out that the void* pointers passed from qsort() to the comparator function have to be computed from the array base pointer by adding an offset. You could have just said so without a long-winded rhetorical question. In fact, perhaps you could just go ahead and make whatever point you're trying to make. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"