Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
_kst_
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
26 ms
·
271.
▲
by
_kst_
6y ago
The "any amount of arguments you want" applies to C function call. The mechanism for invoking your "main" function might use a different mechanism. The C standard specifies (for hosted implementations) two ways to define
272.
▲
by
_kst_
6y ago
All those "pedantic details" let you know how you can write code that a future version of your compiler won't quietly break.
273.
▲
by
_kst_
6y ago
For a freestanding implementation, the program entry point is entirely implementation-defined. It may or may not be called "main". In that kind of environment, "void main()" (or, better, "void main(void)") migh
274.
▲
by
_kst_
6y ago
http://www.avabodh.com/cin/programstructure.html ... void main() ... That's where I stopped reading. Since this comment is getting downvotes, I'll explain. The "void" keyword was in
275.
▲
by
_kst_
6y ago
My own policy is to ask the person who arranged the interview what I should wear. In the absence of specific requirements, I'll dress reasonably nicely (long sleeve collared shirt, etc, no tie -- a level or so up from what I normally w
276.
▲
by
_kst_
6y ago
You can compare it for (in)equality to another void pointer.
277.
▲
by
_kst_
6y ago
I'm a heavy vim user, but I still prefer the emacs-style key bindings for bash. If I want to do vim-style editing on the command line, I sometimes use Ctrl-X Ctrl-E to edit the line in my default editor (which is vim). YMMV, of course
278.
▲
by
_kst_
6y ago
For some reason I don't see a reply link on lewisgodowski's comment. > Couldn't replying to their tweet be considered sending it to Disney? Disney apparently does "consider" that to be sending it to Disney. Since
279.
▲
by
_kst_
6y ago
My reply: #MayThe4th @DisneyPlus Permission denied, Mickey.
280.
▲
by
_kst_
6y ago
Except that tweets aren't sent to Disney. They're sent to all Twitter users.
281.
▲
by
_kst_
6y ago
> or since int is default type Not since the 1999 ISO standard. > int main(){ return linux > unix; } A conforming compiler must diagnose "linux" and "unix" as undeclared identifiers. Many C compilers are not con
282.
▲
by
_kst_
6y ago
It's not a bug. 0xfffe+0x0001 satisfies the syntax of a "preprocessing number". In a later translation phase, preprocessing numbers are converted to numeric constants. Not all valid preprocessing numbers are valid numeric co
283.
▲
by
_kst_
6y ago
C could have permitted pointer+integer and banned integer+pointer, which would have made the indexing operator non-commutative. Nothing important (IMHO) would have been lost. But the equivalence goes back to the days when the distinction
284.
▲
by
_kst_
6y ago
The argument to sizeof is evaluated if and only if it's of a variable length array type. (If it's a parenthesized type name, it's unclear what it means to "evaluate" it.)
285.
▲
by
_kst_
6y ago
In C and C++, a char is by definition a byte. A byte is CHAR_BIT bits, where CHAR_BIT is required to be at least 8 (and is exactly 8 for the vast majority of implementations). The word "byte" is commonly used to mean exactly 8 bit
286.
▲
by
_kst_
6y ago
Yeah, that's one plausible explanation. (I don't remember the nature of the letter.) Relatedly, one time I picked up a prescription for a cat. The cat's name was listed as CatFirstName MyLastName. They had another (human) cli
287.
▲
by
_kst_
6y ago
A former coworker had the last name "Person". They once received a letter (snail mail) addressed to "TheirFirstName Human". I never figured out what kind of mistake could have led to that.
288.
▲
by
_kst_
6y ago
isascii() is not defined by ISO C. (It is defined by POSIX, but POSIX says it may be removed in a future version.) I see that POSIX explicitly says that isascii(x) is "defined on all integer values" (it should have said "all
289.
▲
by
_kst_
6y ago
> I read your code and it seems to me very clear that INT_MIN is exactly what the programmer intended. Well, I'm the author and that's not what I intended. I used INT_MAX as the initial value because it was a simple example. Im
290.
▲
by
_kst_
6y ago
It's a bit dated (it hasn't been updated since 2005), but apart from that I'll say that parts of it are excellent. In particular, section 6 is the best resource I know of for explaining the often counterintuitive relationsh
291.
▲
by
_kst_
6y ago
Plain char is either signed (same representation as signed char) or unsigned (same representation as unsigned char), depending on the implementation. Yes, there are real-world implementations where plain char is unsigned.
292.
▲
by
_kst_
6y ago
Which is why I usually convert to intmax_t or uintmax_t, or to some type that I know is wide enough: uint64_t foo = ...; printf("foo = %ju\n", (uintmax_t)foo); /* OR */ printf("foo = %llu\n",
293.
▲
by
_kst_
6y ago
typedef, in spite of the name, doesn't create a new type. It only creates a new name for an existing type. Changing that would break existing code. I wouldn't mind seeing a new feature that does define a new type (one that'
294.
▲
by
_kst_
6y ago
A quibble on wording: Unsigned overflow is not "twos-complement". It gives you the same bit patterns that typical two's-complement overflow gives you, but strictly speaking two's-complement is a representation for signe
295.
▲
by
_kst_
6y ago
Right, there are (at least) two ways to describe this. One is that unsigned arithmetic can overflow, and the behavior on overflow is defined to wrap around. Another is to say that unsigned arithmetic cannot overflow because the result wraps
296.
▲
by
_kst_
6y ago
What about giving isdigit and friends defined behavior for any argument value that's within the range of any of char, signed char, or unsigned char? The background (I know Doug knows this): isdigit() takes an argument of type int, whic
297.
▲
by
_kst_
6y ago
strchr() is one of several C library functions that have this issue. C++ solved this by overloading strchr(): const char *strchr(const char *s, int c); char *strchr(*char *s, int c); C of course doesn't have overloading. O
298.
▲
by
_kst_
6y ago
Pointer equality (the == and != operators) is well defined for any pointers (of the same type) to any objects. Relational operators (< <= > >=) on pointers have undefined behavior unless both pointers point to elements of the
299.
▲
by
_kst_
6y ago
No, they're converted. There is no such thing as an "implicit cast". And it's not specific to arguments in function calls. Array types and pointer types are distinct. An expression of array type is, in most but not all c
300.
▲
by
_kst_
6y ago
> Now that C2x plans to make two's complement the only sign representation, is there any reason why signed overflow has to continue being undefined behavior? I presume you'd want signed overflow to have the usual 2's-compl
More ›