Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Unexpected and difficult to understand SIGSEGV Date: Thu, 01 Oct 2015 09:28:14 -0700 Organization: None to speak of Lines: 43 Message-ID: References: <5608591F.8020005@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="14989"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gNQd9OlaiebfCGxg609jv" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:XphpDk99hiBBAJ8b9ukJ6virsPs= sha1:Kaw93kUdzRCYvxoul8o1wyeuMGA= Xref: csiph.com comp.lang.c:71548 ais523 writes: [...] > Having to write each prototype twice (once in the declaration and once > in the definition) is something that annoys me too, but I agree with the > prevailing comp.lang.c opinion that using a macro for it (and thus > making the names of the argument unclear from the definition) is unwise. > > However, I've had some thoughts about removing the duplication the other > way instead. The idea would be to look at a source file, and > automatically extract prototypes from all the function definitions > (tools that do this already exist, although IIRC they're mostly dying > out because they were mostly used to convert between prototype-based > and K&R C, and K&R C is mostly dead). Then the tool would write a header > file containing all the declarations. [...] It's an interesting idea, and it probably already exists in some form, but I'm not convinced that it would be worthwhile (at least for me). When I create a pair of .h/.c files (or, in my recent work, .h/.cpp, but the same principles apply), I typically start with the .h file, then copy it to the .cpp file, then expand the declarations to definitions. If I need to update something (which is inevitable), I typically edit both files, make the changes in one, and copy-and-paste into the other. (I use vim, but any decent editor should make it to switch quickly between two files, copying from one and pasting into the other.) Having to copy-and-paste, and maintain the same lines of code in two different files, is mildly annoying, but for me that's outweighed by the advantage of having the *information* clearly visible in both places. If I were using development tools that actually required me to manually type the declaration twice, I'd be interested in an automated tool, but a little copy-and-pasting is easy. -- 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"