Jump to content

Talk:C standard library

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Remove drive-by tagging by three-edit one-day anon IP

[edit]

[1]MaxEnt 23:46, 20 March 2014 (UTC)[reply]

"Three-edit one-day anon" isn't a valid reason (this could be anyone who edited from an uncommon location). But the fact that there's nothing clearly "misleading" and no clarification is. — Vano 00:53, 21 March 2014 (UTC)[reply]
Yeah, IP addresses are human too, but the hatnote wasn't appropriate; I'd like to know what looked so misleading? — Dsimic (talk | contribs) 19:00, 22 March 2014 (UTC)[reply]

About subarticles (e.g. C mathematical functions)

[edit]

There are links to a site called cppreference.com (and almost all subarticles has those links) and it looks like WP:SOAP and I think (for example) the link to [2] should be replaced with [3] or [4]. What do you think? --betseg (talk) 21:13, 15 November 2015 (UTC)[reply]

I don't know the background but a quick look shows cppreference.com is pretty good. By the way, WP:SOAP is referring to advocacy (arguing, for example, in favor of a particular political outlook). I guess you are suggesting the website is being promoted (WP:PROMO). I don't know, but evidence for that would be if a small number of editors were focusing on adding that link. Issues such as whether a link is spam are normally discussed at WP:ELN whereas there might be more attention to which is the best C reference at WT:COMP, with a link to the discussion at Talk:C (programming language) and here. Johnuniq (talk) 22:11, 15 November 2015 (UTC)[reply]
cppreference.com is "at top" or "near top" of C function searches on google, just like Wikipedia, so they can't be all bad. I've used those links and their information is pretty good. I like how they state the section number for each C/C++ specification. • SbmeirowTalk01:58, 16 November 2015 (UTC)[reply]
Or maybe the site is at top because Wikipedia has a lot of links to the site? That's how Google works. --betseg (talk) 05:32, 19 November 2015 (UTC)[reply]
The engine automatically adds rel="nofollow" to every external link to prevent search engines from considering them in ranking - specifically to discourage this kind of "promotion". Though I agree that a site shall be judged solely by its content rather than position in a search result. — Vano 10:50, 20 November 2015 (UTC)[reply]
I think {{man}} would be the perfect thing to use.--betseg (talk) 12:08, 22 November 2015 (UTC)[reply]

Linking libm on linux

[edit]

None of the linux distributions, over the past 18 years, I have every used, have required me to link with libm. The claim that you *must* link with -lm seems dubious if not outright wrong. Can anyone confirm that this real today? — Preceding unsigned comment added by 188.176.25.249 (talk) 09:18, 12 February 2019 (UTC)[reply]

Reading the page, I believe it's only saying you need -lm if you actually use any math functions (sqrt, sin, etc.), which comports with my experience. SJFriedl (talk) 21:56, 6 June 2020 (UTC)[reply]

A Commons file used on this page or its Wikidata item has been nominated for speedy deletion

[edit]

The following Wikimedia Commons file used on this page or its Wikidata item has been nominated for speedy deletion:

You can see the reason for deletion at the file description page linked above. —Community Tech bot (talk) 19:09, 18 August 2022 (UTC)[reply]

India Education Program course assignment

[edit]

This article was the subject of an educational assignment supported by Wikipedia Ambassadors through the India Education Program.

The above message was substituted from {{IEP assignment}} by PrimeBOT (talk) on 19:55, 1 February 2023 (UTC)[reply]

Alternate names

[edit]

WRT "The C standard library or libc": I think the term libc is rather *nix specific and therefore should not be implied to be such a common alternate name. IMO libc should be introduced later in the context of *nix implementations.

WRT "the C standard library is also called the ISO C library": IDK. I've never hear of that and google trends says it's very obscure: no history in US since 2004! A search on "ISO C library" does of course find this WP page, but this is a case of WP making a term notable ... which it's not supposed to do. Stevebroshar (talk) 17:20, 20 October 2024 (UTC)[reply]

The page discusses those library routines and macros that are specified by the ISO C standard. How that's done is platform-dependent. UN*Xes have traditionally provided a library, linked by default by the C compiler driver command (cc, gcc, clang, etc.), *usually* called "libc", as in "a file containing those routines has a name consisting of 'libc' followed by the appropriate extension, such as '.a' for a static library and '.so' (SunOS 4 and all systems using ELF), '.dylib' (macOS and other Apple OSes using Mach-O), '.sl' (32-bit HP-UX), or even '.a' (AIX) for a dynamically-linked shared library". However, it's called "libSystem" on Apple's OS.
On UN*Xes, that library also contains UN*X-specific APIs, such as open(), read(), write(), lseek(), close(), getpwuid(), etc.; perhaps that's why macOS (and NeXTSTEP?) renamed it "libSystem". On some UN*Xes, some UN*X APIs, e.g. socket APIs, may be in yet another library, not linked by default. I remember, at one point during the AT&T/Sun discussions about SVR4, AT&T made a proposal to break up libc into multiple libraries, including separating C language support routines and UN*X APIs, but that didn't happen.
On other platforms, there may be separate libraries for native OS APIs and standard C routines, although the "standard C routines" library may have additional routines, as is the case on Windows with Visual Studio.
So, yeah, at most it should speak of "libc" as being an idiom used on UN*Xes, rather than an alternate name.
As for the ISO standard, ISO/IEC 9899:2018 appears to refer to the "standard library" in some places, but that's about it. Guy Harris (talk) 18:04, 20 October 2024 (UTC)[reply]
I've changed it to say "The C standard library, sometimes referred to as libc, is the standard library for the C programming language,", and to ask for a citation on "sometimes referred to as libc", and also asked fo a citation on "ISO C library". Guy Harris (talk) 19:41, 20 October 2024 (UTC)[reply]

ANSI/ISO...

[edit]

WRT "The C standard library ... is the standard library for the C programming language, as specified in the ISO C standard" That's not wrong, but it's overly specific and confuses the topic and reader. The ANSI C standard also defines a c standard lib. I think the intro should start with simply "The C standard library is the standard library for the C programming language". Later say that there have been multiple versions over time; first from ANSI, then later from ISO. IMO standardization is subordinate to what the library _is_. Stevebroshar (talk) 17:43, 20 October 2024 (UTC)[reply]

What is __STDC_HOSTED__?

[edit]

WRT "According to the C standard the macro __STDC_HOSTED__ shall be defined to 1 if the implementation is hosted. A hosted implementation has all the headers specified by the C standard. An implementation can also be freestanding which means that these headers will not be present. If an implementation is freestanding, it shall define __STDC_HOSTED__ to 0."

What is that saying? If the value is 1, then the implementation (preprocessor? compiler? linker? toolset? app?) is hosted and that it (what ever it is) has all the c standard headers. If the value is 0, then it's freestanding which means it doesn't have all the headers. Freestanding means it has less than the full set? Really? That's confusing naming.

Whatever this macro actually does... I don't think it belongs in this article. Seems too technical for this context. Stevebroshar (talk) 17:51, 20 October 2024 (UTC)[reply]

What the standard says, as of C19, is:
5.1.2.1 Freestanding environment
In a freestanding environment (in which C program execution may take place without any benefit of an operating system), the name and type of the function called at program startup are implementation-defined. Any library facilities available to a freestanding program, other than the minimal set required by Clause 4, are implementation-defined.
The effect of program termination in a freestanding environment is implementation-defined.
5.1.2.2 Hosted environment
A hosted environment need not be provided, but shall conform to the following specifications if present.
5.1.2.2.1 Program startup
[The first function called is main(), and it gets handed an argument list.]
5.1.2.2.2 Program execution
In a hosted environment, a program may use all the functions, macros, type definitions, and objects described in the library clause (Clause 7).
5.1.2.2.3 Program termination
[If main() returns, it's just as if the program called exit() with the return value.]
As I remember, this was done to support both "C as a programming language atop an operating system" and "C as a programming language for writing code that might run directly on the hardware of an embedded system". For the latter, there's no guarantee that, for example, there's any of the I/O facilities, as your program might, for example, only have, as I/O devices, a couple of buttons, a couple of lights, and a voltage sensor - not much there to fprintf() to.
So:
If the value is 1, then the implementation (preprocessor? compiler? linker? toolset? app?) is hosted and that it (what ever it is) has all the c standard headers. Yes, and what the components of the implementation are is either implementation-defined or undefined, probably the latter. There may or may not be a preprocessor as a separate tool; there may be an interpreter rather than a compiler; there may be a run-and-go compiler and no linker; the toolset is whatever tools are supplied; there may not be an "app" in the sense of an IDE with a non-command-line user interface. And, yes, it has all the C standard headers, and makes available all of the C standard library routines.
If the value is 0, then it's freestanding which means it doesn't have all the headers. It is not guaranteed to have any of the headers other than the ones required by the standard to be present in freestanding implementations (in C18, that's <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and <stdnoreturn.h>), and it is not guaranteed to have any of the library routines other than those specified by those headers. The standard says, of C implementations, that "A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program." - a footnote means that "do not alter..." includes not defining functions not specified in the standard, e.g. it can't define open(), as that might collide with a function in a srictly conforming program (which is why Visual Studio's UN*X-alike routines have names such as _open()).
Freestanding means it has less than the full set? Really? YA RLY. An embedded C implementation might, for example, have sprintf() to format a message to display on a display panel, but not have anything to which to do a printf() or fprintf().
That's confusing naming. I guess the idea is that a "hosted" implementation is "hosted" by, i.e. running on top of, an operating system, whereas a "freestanding" implementation might run on bare hardware, standing by itself with no host.
Whatever this macro actually does... I don't think it belongs in this article. The macro probably belongs in C (programming language), rather than here, as it pertains to C as a whole, not just the library. Hosted vs. freestanding also mainly belongs there, although it's worth mentioning here, as it governs which of the routines here are guaranteed to be available. Guy Harris (talk) 19:00, 20 October 2024 (UTC)[reply]