Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #136720
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: GCC and const-correctness |
| Date | 2018-10-12 13:21 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <ppq049$nad$1@dont-email.me> (permalink) |
| References | <20181011121731.c7a6e66e8ce7f5410984b007@g{oogle}mail.com> <ZsLHsGEefNhyaQ54CFWzJQr9nogBt@bongo-ra.co> <slrnprupfc.f78.grahn+nntp@frailea.sa.invalid> <4g649f-v97.ln1@gangtai.home.grep.be> <slrnps0t4a.f78.grahn+nntp@frailea.sa.invalid> |
On 12/10/18 12:16, Jorgen Grahn wrote:
> On Thu, 2018-10-11, Wouter Verhelst wrote:
>> On 11/10/18 17:02, Jorgen Grahn wrote:
>>> On Thu, 2018-10-11, Spiros Bousbouras wrote:
>>>> On Thu, 11 Oct 2018 12:17:31 +0300
>>>> Anton Shepelev <anton.txt@g{oogle}mail.com> wrote:
>>> ...
>>>>> static void test( const char * s )
>>>>> {}
>>> ...
>>>
>>>> By the way , if I were a compiler writer I would offer a warning for a
>>>> function with no code and also offer some way to disable such warnings.
>>>
>>> Better IMO to not habitually create empty functions. If you just
>>> /declare/ a function as a placeholder instead of /define/ it, you
>>> can't forget to go back and fill it in.
>>
>> The downside of that is that this makes it impossible for you to link
>> the program as soon as you use one of the declared-but-not-implemented
>> functions. That makes it harder to test the parts of the application
>> that you *did* write.
>
> It's also the upside: as a rule, I don't want the code to link if it's
> that incomplete.
A convenient method is to use :
void test(void) {
#warning Function "test" is not yet implemented
}
In early stages of development, when you might want compiling and
linking to work despite known problems, you let this and other warning
messages slide. Once the program starts to take shape and you need to
get more details in place, put "-Werror" in your Makefile and (to Bart's
joy) do a clean build. From now on, these unimplemented functions will
fail to compile and can't be forgotten.
>
> I may write unit tests for the other parts. Or, if I *do* have unit tests
> which fail because of it, I can accept having an empty function definition
> like you suggest.
>
> And of course: YMMV.
>
> /Jorgen
>
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
GCC and const-correctness Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-10-11 12:17 +0300
Re: GCC and const-correctness Philipp Klaus Krause <pkk@spth.de> - 2018-10-11 11:22 +0200
Re: GCC and const-correctness Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-10-11 13:17 +0300
Re: GCC and const-correctness Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-10-11 02:40 -0700
Re: GCC and const-correctness Spiros Bousbouras <spibou@gmail.com> - 2018-10-11 10:17 +0000
Re: GCC and const-correctness Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-10-11 13:28 +0300
Re: GCC and const-correctness Spiros Bousbouras <spibou@gmail.com> - 2018-10-11 10:58 +0000
Re: GCC and const-correctness jameskuyper@alumni.caltech.edu - 2018-10-11 08:21 -0700
Re: GCC and const-correctness David Brown <david.brown@hesbynett.no> - 2018-10-11 12:39 +0200
Re: GCC and const-correctness Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-10-11 15:02 +0000
Re: GCC and const-correctness Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-10-11 18:06 +0300
Re: GCC and const-correctness Wouter Verhelst <w@uter.be> - 2018-10-11 17:23 +0200
Re: GCC and const-correctness Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-10-12 10:16 +0000
Re: GCC and const-correctness David Brown <david.brown@hesbynett.no> - 2018-10-12 13:21 +0200
Re: GCC and const-correctness Wouter Verhelst <w@uter.be> - 2018-10-13 09:33 +0200
Re: GCC and const-correctness David Brown <david.brown@hesbynett.no> - 2018-10-13 13:11 +0200
Re: Empty functions (was: GCC and const-correctness) Wouter Verhelst <w@uter.be> - 2018-10-11 17:25 +0200
Re: Empty functions (was: GCC and const-correctness) Keith Thompson <kst-u@mib.org> - 2018-10-11 09:23 -0700
Re: Empty functions (was: GCC and const-correctness) Keith Thompson <kst-u@mib.org> - 2018-10-11 10:54 -0700
Re: Empty functions (was: GCC and const-correctness) Wouter Verhelst <w@uter.be> - 2018-10-11 19:56 +0200
Re: Empty functions David Brown <david.brown@hesbynett.no> - 2018-10-11 20:19 +0200
Re: Empty functions (was: GCC and const-correctness) Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-10-12 02:43 -0700
Re: Empty functions (was: GCC and const-correctness) Anton Shepelev <ant0n.txt@gmai1.c0m> - 2018-10-11 19:16 +0300
csiph-web