Talk:C date and time functions
![]() | C/C++ Unassessed | |||||||||
|
Wikipedia is not C documentation.
- Why not? What else would you put here? --a_dergachev 07:58, 8 October 2007 (UTC)
- He is correct, see WP:NOT#HOWTO. -- intgr [talk] 14:18, 8 October 2007 (UTC)
- Yeah Guys.. Just something to think about.. An encyclopedic Article on time.h would be - well just useless. And i'm happy with the english wikipedia as it is, with thousands of articles to even minor details, headerfiles, comic characters and so on. Please just don't take the german wiki as model, its so full of relevancy that it became entirely irrelevant. Rules like the NO-HOWTO are nice, but only IF the article would be better in an encyclopedic form - not in this case.77.11.26.13 (talk) 20:43, 16 February 2010 (UTC)
Move discussion in progress
There is a move discussion in progress which affects this page. Please participate at Talk:C standard library - Requested move and not in this talk page section. Thank you. —RM bot 09:40, 8 November 2011 (UTC)
time_t
Regarding the "time_t - time since epoch type". This is not true actually as shown in the specification http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf See on page 350 at 7.23.1.(4) Components of time: "The range and precision of times representable in clock_t and time_t are implementation-defined.". Thus, it should be "time_t - time since epoch type for most compilers such as gcc"! (see http://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_21.html) — Preceding unsigned comment added by 195.244.120.156 (talk) 13:55, 23 November 2011 (UTC)
- I don't understand what was wrong with the previous statement.
time_t
means "time since epoch" or "calendar time" in all contexts as per specification. The undefined thing is the format of the type, not what it represents. Thus since the previous definition doesn't specify anything about the format, it's still correct. 1exec1 (talk) 16:28, 23 November 2011 (UTC)
Proposed rename
I propose to rename the article from C date and time operations to C date and time functions per WP:COMMONNAME. 1exec1 (talk) 16:29, 23 November 2011 (UTC)
- Since I've received exactly zero input, I've moved the page. If anyone disagrees, please express your concerns here. Thanks. 1exec1 (talk) 16:20, 25 November 2011 (UTC)
whitespace and compilation
Recently an anonymous editor changed the whitespace from simple spaces to tabs, claiming "UNIX-style indentation" had to be with tabs, not spaces. I reverted this because a) whitespace in C can be spaces, horizontal tabs, vertical tabs and newlines, b) UNIX-style does not restrict it to tabs only, c) those massive, wide tabs seem un-aesthetic to me (that's a personal thing but the industry seems to like 3 or 4 space indentation) and d) even under flame war discussions, the original indentation was perfectly serviceable. He also claimed that (void) has to be used when the return value of printf() is ignored. It certainly can be used that way but is by no means required. To my mind, this cast gets in the way of this example. A clean, minimal source is preferred so that the topic under discussion is highlighted, without distractions. Lastly, he also added a sample compilation and invocation. This only applies to UNIX and doesn't take into account compilation and invocation under Windows, Macs, cross compilers for embedded systems, etc. This isn't an article on compiling and invoking C programs. For users not used to Unix, they now have to figure what parts of that are the commands, what parts are the prompts and what part is the actual output. Much better to simply show the output and leave it at that. Thoughts? Stepho talk 00:18, 11 March 2012 (UTC)
- I agree with all your points. I would add that indentation isn't only a personal thing - Wikipedia prefers consistent style. If we look around, we will see that most of the examples use the original indentation style. So I'd support reverting the changes to the indentation too. 1exec1 (talk) 23:49, 11 March 2012 (UTC)
- As for indentation, it isn′t about consistency on Wikipedia, but is about conforming to the common style of the industry. 213.131.238.28 (talk) 09:38, 12 March 2012 (UTC)
- That anonymous editor was me. First, I′m a C expert and as such am aware that C is a free-form language, allowing both spaces and tabs as whitespace (along with a few other characters); I never claimed tabs to be the sole delimiter — that′s why I wrote “UNIX-style indentation”, alluding to mere stylistic nature of the matter. It isn′t important whether to use spaces or tabs in such code snippets, the indentation part of my edit was purely aesthetical, made in accordance to my personal (and quite popular) views:
- Tab is more flexible, because most text editors allow you to set the tab width, allowing for quick indentation adjustments without any changes to the actual code.
- Tab is far more common as an indentation character and is used extensively throughout the industry — this is why your industry comment is false — industry uses tabs with tab width set to either 4 or 8 (never odd, like 3), you can easily see that for yourself by examining source code (quick examples: Solaris, IRIX, Linux, and FreeBSD kernels.) I am myself part of this industry, being a C programmer for Cadence Design Systems, Inc. You are, on the contrary, either an amateur or most likely not a C programmer at all, which is easily deduced from your comment on industrial usage of tabs — apparently you never even read any source code of operating systems, drivers, or system software, otherwise you wouldn′t make that erroneous statement. This is why my professional opinion holds a much higher value.
- Tab is more practical, because it takes less bytes to represent a string of tabs compared to a string of spaces of the same visible width.
- Tab is very handy for automated code editing by scripts (regular expressions become ten times simpler, compared to equivalents written for space-indented code) — the technique used extensively throughout the industry for large spanning source trunks and branches.
- By using tabs for indentation of example code snippets on Wikipedia we promote a reasonable, practical, and just handy coding technique, which, in common sense, is a virtue to be chased. Moreover, I noted UNIX because it is the origin of the C programming language, its source code therefore can and should be taken as a reliable source of good C programming practices, including the style.
- Second, I never claimed the void cast to be required — I wrote should, indicating its optional nature. Such void casts are deemed to be a good practice, because just by glancing at code you can easily tell which calls′ return values are ignored. It is a heavily used (by industry, yeah) convenience technique of the same order as prefixing struct/union member names with struct/union′s shortened name, for example:
struct iovec {
void *iov_base;
size_t iov_len;
};
- But okay, your point here is reasonable, so let′s keep the cast out and leave it to industry. I agree with your compilation and invocation point too — I tend to forget that non-UNIX operating systems exist, my bad.
- Resume: you twisted every single bit of my edit′s explanation message, reading “required” instead of “optional” and not undestanding the stylistic nature of tab usage. You aren′t even a professional C programmer. Why do you edit C-related articles when you aren′t knowledgeable enough?
Au revoir. 213.131.238.28 (talk) 09:38, 12 March 2012 (UTC)