

Shit so bleak programmers learn new languages now by coding “goodbye world”
https://eel.is/c++draft/defns.impl.defined
https://eel.is/c++draft/defns.unspecified
(so e.g. where the standard says that the details of searching for a header file for an ` #include` are implementation-defined, that means the compiler vendor needs to document its rules for header searching (otherwise it's not a conforming implementation).)
https://eel.is/c++draft/defns.impl.defined
https://eel.is/c++draft/defns.unspecified
(so e.g. where the standard says that the details of searching for a header file for an ` #include` are implementation-defined, that means the compiler vendor needs to document its rules for header searching (otherwise it's not a conforming implementation).)
Linux kernel quiz: Why is this program so slow and takes around 50ms to run?
What line do you have to add to make it run in 3ms instead without interfering with what this program does?
user@debian12:/test$ cat > slow.c
#include
#include
#include
#include
static void open_sockets(void) {
for (int i=0; i<256; i++) {
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1)
err(1, "socket");
}
}
static void *thread_fn(void *dummy) {
open_sockets();
return NULL;
}
int main(void) {
pthread_t thread;
if (pthread_create(&thread, NULL, thread_fn, NULL))
errx(1, "pthread_create");
open_sockets();
if (pthread_join(thread, NULL))
errx(1, "pthread_join");
return 0;
}
user@debian12:/test$ gcc -O2 -o slow slow.c -Wall
user@debian12:/test$ time ./slow
real 0m0.041s
user 0m0.003s
sys 0m0.000s
user@debian12:/test$ time ./slow
real 0m0.053s
user 0m0.003s
sys 0m0.000s
user@debian12:/test$
Linux kernel quiz: Why is this program so slow and takes around 50ms to run?
What line do you have to add to make it run in 3ms instead without interfering with what this program does?
user@debian12:/test$ cat > slow.c
#include
#include
#include
#include
static void open_sockets(void) {
for (int i=0; i<256; i++) {
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1)
err(1, "socket");
}
}
static void *thread_fn(void *dummy) {
open_sockets();
return NULL;
}
int main(void) {
pthread_t thread;
if (pthread_create(&thread, NULL, thread_fn, NULL))
errx(1, "pthread_create");
open_sockets();
if (pthread_join(thread, NULL))
errx(1, "pthread_join");
return 0;
}
user@debian12:/test$ gcc -O2 -o slow slow.c -Wall
user@debian12:/test$ time ./slow
real 0m0.041s
user 0m0.003s
sys 0m0.000s
user@debian12:/test$ time ./slow
real 0m0.053s
user 0m0.003s
sys 0m0.000s
user@debian12:/test$
Dear C++ #CPP people: how do you actually fucking do this? It seems bad enough that I need to have two overloads just to allow for the "no args" version.
But that template overload fails at link time because of an undefined symbol???
UPDATE: It’s because I needed to define it in the header file itself, not just declare it
template <typename... Args>
void info(std::format_string<Args...> fmt, Args&&... args) {
auto res = std::format(fmt, std::forward<Args&&>(args)...);
std::println("{}", res);
}
int main() {
info("{}", 42);
info("moi");
}
```
Seems to work in compiler explorer. Typos might be present, writing this on phone. Did you need something else?
Failing on link time might happen if you have template in a source code file not visible to an another translation unit (which is why we write template code into headers, or modules if we're in the future).
Trump's lawsuit against WSJ appears to argue that since they called it an "exclusive" they shouldn't have published it widely? HUH?
This was fun - missing.c:
void die(int err, char *msg) {
err? fprintf(stderr, "%s\n", msg), exit(1): 0;
}
int main(int argc, char *argv[]) {
int n, answer = 1, val;
die(argc != 2 || (n = atoi(argv[1])) < 2, "Usage: missing n");
for (; n > 1; n--) {
die(scanf("%d", &val) != 1, "Error reading input");
answer ^= val ^ n;
}
printf("%d\n", answer);
}
This was fun - missing.c:
void die(int err, char *msg) {
err? fprintf(stderr, "%s\n", msg), exit(1): 0;
}
int main(int argc, char *argv[]) {
int n, answer = 1, val;
die(argc != 2 || (n = atoi(argv[1])) < 2, "Usage: missing n");
for (; n > 1; n--) {
die(scanf("%d", &val) != 1, "Error reading input");
answer ^= val ^ n;
}
printf("%d\n", answer);
}
Linux kernel 6.12.35 introduces a build regression.
.../tools/include/linux/kallsyms.h:21:10: fatal error:
execinfo.h: No such file or directory
21 | #include
| ^~~~~~~~~~~~
I hope this does not mean that GNU libc is required to build kernel now.
Linux kernel 6.12.35 introduces a build regression.
.../tools/include/linux/kallsyms.h:21:10: fatal error:
execinfo.h: No such file or directory
21 | #include
| ^~~~~~~~~~~~
I hope this does not mean that GNU libc is required to build kernel now.
A space for Bonfire maintainers and contributors to communicate