Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
_kst_
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
31 ms
·
331.
▲
by
_kst_
7y ago
"If it was flying by slowly, it would get caught by the sun’s gravity and end up in a circular orbit around the sun. If the orbit was perfectly circular, it would have an eccentricity of 0." An interstellar object cannot be flying
332.
▲
by
_kst_
7y ago
How did you get the older Perls working? (I've tried and failed to get them to build on Ubuntu.)
333.
▲
by
_kst_
7y ago
Pointers and arrays are not the same thing. See section 6 of the comp.lang.c FAQ, http://www.c-faq.com/ . I doubt that C++ was ever a strict superset of C. Has int class; ever been a valid declaration in C++?
334.
▲
by
_kst_
7y ago
The C standard permits implementations to support additional forms of constant expressions. Try "clang -std=c11 -pedantic-errors".
335.
▲
by
_kst_
7y ago
I said enumeration constants are of type int. For example, given: enum foo { this, that, the_other }; enum foo obj; obj is of type "enum foo", which is compatible with some implementation-defined integer type, but t
336.
▲
by
_kst_
7y ago
For non-variadic functions, the argument is implicitly converted to the parameter type (if possible). For variadic functions, the compiler doesn't know the parameter type. So to print a null pointer, you need to do this: printf(&
337.
▲
by
_kst_
7y ago
N1570 6.7.9p11 says that the constraints and conversions for simple assignment apply to scalar initializers. 6.5.16.1p1 says that, for pointers, "the type pointed to by the left has all the qualifiers of the type pointed to by the righ
338.
▲
by
_kst_
7y ago
Yes, but only for constants of type int. For example, this is valid: enum { ANSWER = 42 }; But C enumeration constants are always of type int, so you can't define a constant of some other integer type this way.
339.
▲
by
_kst_
7y ago
Several of the examples shown as valid C are not. For example, this: const int foo = 1; int* bar = &foo; *bar = 2; is said to have undefined behavior, but in fact the initialization of `bar` is a constraint violation, r
340.
▲
by
_kst_
7y ago
It's Karenina. There's a typo in the title.
341.
▲
by
_kst_
7y ago
strpy() is safe when used safely. That means that you've confirmed that the target is big enough. For example, there's no way this can fail: char s[10]; strcpy(s, "hello"); The problem is that it can also be
342.
▲
by
_kst_
7y ago
C doesn't lack line comments. The obsolete 1989/1990/1995 version(s) of C did lack line comments.
343.
▲
by
_kst_
7y ago
Sorry, in the first example I meant to write (adding a declaration and initialization for n): int n = 42; int vla[n]; sizeof vla; not `sizeof n`). (It doesn't look like I can edit a comment.) Logically, evaluating the
344.
▲
by
_kst_
7y ago
That's non-standard.
345.
▲
by
_kst_
7y ago
And it's not even entirely clear what that means. The standard says: "If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer const
346.
▲
by
_kst_
7y ago
https://stackoverflow.com/q/381542/827263 https://stackoverflow.com/a/18393343/827263
347.
▲
by
_kst_
7y ago
sizeof ('a') doesn't reliably tell you whether you're compiling C or C++. It yields the same result in an implementation where sizeof (int) == 1 (which requires CHAR_BIT >= 16). (The difference is that character const
348.
▲
by
_kst_
7y ago
It appears not to be. The earlier Legion was developed at the University of Virginia. I see no reference to it on the web page or in the sources on GitHub. https://en.wikipedia.org/wiki/Legion_(software)
349.
▲
by
_kst_
7y ago
UNIX timestamps are normally stored as 32-bit or 64-bit signed integers, not as floating-point. If you want better than 1-second precision, then the type "struct timespec" (specified by POSIX) gives you nanosecond precision. Fixed
350.
▲
by
_kst_
7y ago
It's been corrected in the repo, but as I write this the web page has not been updated.
351.
▲
by
_kst_
7y ago
I submitted a GitHub issue for the `main()` definitions and some other quibbles. https://github.com/akalenuk/wordsandbuttons/issues/12
352.
▲
by
_kst_
7y ago
No, for the cases that involve undefined behavior, the results can differ arbitrarily depending on compiler settings, optimization settings, the presence of seemingly irrelevant code, or, in principle, the phase of the moon. The behavior of
353.
▲
by
_kst_
7y ago
By convention on Stack Overflow and other Stack Exchange sites, voting works differently on the meta.* sites. On the main sites, downvoting means "this is a bad question or answer" or "this answer is incorrect". On the m
354.
▲
by
_kst_
7y ago
gettimeofday is obsolescent, but its replacement clock_gettime has the same issue. gettimeofday gives you a struct timeval with microsecond resolution. clock_gettime (which takes an extra argument specifying which of several clocks to use)
355.
▲
by
_kst_
7y ago
A small quibble: bzero() is not defined by the C standard. memset() is.
356.
▲
by
_kst_
8y ago
Both were up for me when I tried them just now (12 minutes after your comment).
357.
▲
by
_kst_
8y ago
"If we, what3words ltd, are ever unable to maintain the what3words technology ..., then we will release our source code into the public domain. We will do this in such a way and with suitable licences ..." What are "suitable
358.
▲
by
_kst_
8y ago
https://homes.cs.washington.edu/~weise/uhh-download.html "We wrote the contract with our publisher to have the copyright revert to us once the book went out of print. So yes, we have the right to publish it online
359.
▲
by
_kst_
8y ago
memset_s() is defined in C11 Annex K, which is optional and is not provided by most implementations.
360.
▲
by
_kst_
8y ago
Here's my rant on strncpy: http://the-flat-trantor-society.blogspot.com/2012/03/no-strn...
More ›