Constants having types in C
Posted: Sun Jan 16, 2005 9:13 pm
..
The Place to Start for Operating System Developers
https://f.osdev.org/
The term is "integer suffix", or "floating suffix". It's been in there since K&R, well before C++ came into existence IIRC.Perica wrote: What is the point of appending an: L, f, etcetera; to constants in C (which I call "constant data-typing" ... I don't know the official term for it)?
First off, you seldom have any need for it. If you provide a constant without suffix, the compiler just choses an appropriate type. (The smallest of [tt]int[/tt], [tt]long int[/tt] or - in C99 - [tt]long long int[/tt] that can hold the value, or [tt]double[/tt] for floating point values.)Why does this requirement exist in the language at all?
The [tt]UINTN_C[/tt] and [tt]INTN_C[/tt] macros expand a given constant to type uint_leastN_t and int_leastN_t, respectively. If you are using those, you seem to have very specific requirements for the types of your data, or you would just work with the basic [tt]int[/tt] type. I think that answers your question in itself....this curiosity popped up when writing some C code that uses the type definitions in the stdint.h header of the standard C library - I just find it a neusance having to use the UINT*_C and INT*_C macros all over the place, in order to maintain compiler compatibility - all because of this "constant data-typing").
ANSI C (X3.159-1989) was ratified in 1989 and published in 1990, followed up by the (identical) ISO standard ISO/IEC 9899:1990. This (including technical corrigenda) is what GCC does with --std=c89.Perica wrote: By the way: is C99 just a short name for the C or C++ standards (or both :-\)?
Although I'm not familiar with it, I've seen Comeau mentioned a lot on comp.lang.c++.moderated.Which compiler is it? OpenWatcom? The Intel C/C++ Compiler? ... ?
I can't speak to GCC's conformance, but here is some info about VC++ 7.1's conformance, straight from the horse's mouth.Concerning GCC and Visual C++: do they just have minor implementation errors, or something major?
If I'm not mistaking (checking it right now) this is EXACTLY what I thought C++ didn't have and that I really did want. Thank you!Solar wrote: Interesting enough, they were also the ones most adamantly opposing this feature in the standards committee, since it's a ***** to implement. But once it was decided, they implemented it, while the rest went along with a "nobody needs this anyway" - which might be because no-one even knows it should be possible in the first line.