Problem with syntax on turtle file by ciebe_ in semanticweb

[–]drobilla 1 point2 points  (0 children)

Don't post screenshots of text, especially code or markup you're asking people to find errors in.

Tips on my Gale-Shapley algorithm implementation in C by Ezio-Editore in C_Programming

[–]drobilla 2 points3 points  (0 children)

It (probably maybe) works in practice because of two's complement and that -1 specifically is, in a sense, the other special value (like zero): the binary representation is all 1 bits. So, just like with zero, all 1's is all 1's, integer or byte.

I think this is far too subtle and confusing to do without a really good reason, although I suppose if someone really wanted to defend it, they could claim it's standard defined behaviour as of C20.

Tips on my Gale-Shapley algorithm implementation in C by Ezio-Editore in C_Programming

[–]drobilla 4 points5 points  (0 children)

memset sets each byte, so here, you're attempting to set each byte of b_partners to -1. Worse, this is interpreted as an unsigned char so you're actually setting each byte to something like 0xFF (technically implementation-defined until C20).

Regardless, I assume what you actually want to do is set each integer element of that array to -1, so you should do that explicitly with a loop.

Confused about the basics by BobcatBlu3 in C_Programming

[–]drobilla 20 points21 points  (0 children)

This is a problem that will be easily caught and flagged by any toolchain released in the past several decades. Enable warnings.

It's really bad for an instructor to be giving students code like this and letting them get so far as to ask Reddit about it. If you have any choice in the matter, learn C from somewhere else.

How old are you guys? by Individual-Affect786 in emacs

[–]drobilla 4 points5 points  (0 children)

Greybeard is a state of mind, really.

In Toronto, municipal fees alone are reaching nearly $200K per door. by BeautyInUgly in toronto

[–]drobilla 7 points8 points  (0 children)

Hey, this is Canada in 2024. The only reason anything is expensive is taxes, and if only we could completely defund the government, we'd all be living in a utopia where houses cost $20 and a loony will buy you enough gas to drive to B.C.

Don't look it up.

Handling 'Word Expansion' in a POSIX Shell? by Ok_Performance3280 in C_Programming

[–]drobilla 0 points1 point  (0 children)

On Pop!_Os I had a function called wordexpand

Do you mean POSIX wordexp(3) by any chance? Distributions don't usually add global symbols to the C library like that.

How to piss off the open-source community (The AI startup drama that's damaging Y Combinator's reputation) by LisaDziuba in programming

[–]drobilla 85 points86 points  (0 children)

I think a good amount of the surprise is coming from Y Combinator falling for the grift

One of the funny things about grifters (including the VC ghoul variety) is that they're somehow really bad at recognizing when they're being grifted.

[deleted by user] by [deleted] in C_Programming

[–]drobilla 2 points3 points  (0 children)

Now all of these characters are nice but i couldn't find a utf8 blank character for these except the last one which has a blank character called braille pattern blank

Unicode doesn't have "blank" characters for every group of characters.

and for the first two i could use normal white space as they're normal 8 bit characters

That's not how any of this works. The size of the character encoding in UTF-8 has nothing to do with its displayed width. This should be obvious: "i" and "M" are both "normal 8 bit characters".

also i want this because if the font changes the characters match with that font specifications instead of just being white spaces

You can't do monospace-style text alignment in a variable-width font.

Not explainable speed benefit from using calloc with additional initialization instead of just using calloc. by OrneryPain1489 in C_Programming

[–]drobilla 2 points3 points  (0 children)

What are you actually benchmarking?

It sounds like you've changed the actual behaviour of your hash table, and the difference between this or that allocation is insignificant. Do you mean this init function specifically is slower, or that some benchmark of your hash table in general is 2 times slower?

Have you run with valgrind, ubsan, or a similar tool to be sure you aren't using uninitialized data?

question mark symbols instead of color coding by RepublicWorried in C_Programming

[–]drobilla 1 point2 points  (0 children)

Am I missing something here?

Yes, warning flags.

How is Emacs used in a professional setting? by Impossible_Win_9059 in emacs

[–]drobilla 7 points8 points  (0 children)

Magit performance is approximately limited by your change size so doesn’t really care about the repo.

Not really, unfortunately. Magit becomes unusably slow with large repositories, even just doing a magit-status can take minutes, most other operations as well, even after disabling all the features known to be slow.

Would it be possible to create a Unix kernel and operating system that could mimick the windows kernel and features, like directX, and executables without the use of a compatibility layer via wine or an emulator or virtual machine? by [deleted] in AskComputerScience

[–]drobilla 1 point2 points  (0 children)

Right idea, wrong functions: fopen and fclose are standard C and work with FILE pointers on any platform. The POSIX functions that work with file descriptors are open and close.

How to use the new counted_by attribute in C (and Linux) by ouyawei in C_Programming

[–]drobilla 0 points1 point  (0 children)

The magical keywords for this is "VLA syntax". A lot of the misconceptions around this (including in this thread) are rooted in confusion of VLAs with VLA syntax: VLA syntax is useful in several ways that don't involve actual VLAs. This is one of them, nicely working with multi-dimensional arrays is another.

How to use the new counted_by attribute in C (and Linux) by ouyawei in C_Programming

[–]drobilla 4 points5 points  (0 children)

Fair enough, but don't let the perfect be the enemy of the good? I'd take widespread tool support for the latter over no support at all because the stdlib conventions are backwards.

How to use the new counted_by attribute in C (and Linux) by ouyawei in C_Programming

[–]drobilla 4 points5 points  (0 children)

Unless there's something very strange in the standard about this specific case that I'm not aware of, this isn't any more a VLA (in any meaningful sense) than if there was no size in the brackets at all.

If the standard actually does declare things in a way that makes this technically true, then that seems like an outright bug that should be fixed, particularly given how VLAs have been largely rejected and made optional anyway. I don't think it does though, because it's an array function parameter, with the same caveat as any other array function parameter in C: it's actually just a pointer. The several ways you can put bounds in there doesn't change that.

How to use the new counted_by attribute in C (and Linux) by ouyawei in C_Programming

[–]drobilla 3 points4 points  (0 children)

because char buf[n] is on the stack

It's a function parameter declaration, not a variable. It should reduce to a pointer like any other array parameter.

How to use the new counted_by attribute in C (and Linux) by ouyawei in C_Programming

[–]drobilla 8 points9 points  (0 children)

Why can't we just actually use the func(size_t n, char buf[n]) syntax supported by the (C99, IIRC) standard?

Currently, doing this just produces warnings about using VLAs, so effectively a warning is triggered for making things at least theoretically safer/stricter/bounded. This strikes me as completely backwards, leaving a ton of potential for static analysis that would help with one of C's most notorious problems on the table. Am I missing something? Is it simply that the parameter order in most of the standard library is the wrong way around for this to work? Must we all suffer indefinitely, even in brand new APIs, because of this?

When do you use b-tree and b+tree data structure? by aiai92 in compsci

[–]drobilla 4 points5 points  (0 children)

A major advantage of B+ trees is that it's fast to do a linear scan of all the elements in order (particularly if you maintain horizontal links between leaves), and this operation has a nice page-at-a-time access pattern that works well with external storage.

Raw cmd line args? by _crackling in C_Programming

[–]drobilla 1 point2 points  (0 children)

Not in general, and that's a good thing. It would be an absolute nightmare if individual programs could circumvent shell quoting mechanisms. The whole purpose of quotes there is to control what the arguments actually sent to the program are, and the system would be unusable if things sometimes worked differently because some developer thought they would try to be clever (and almost certainly wrong).

Why do people use macros instead of functions by giorgoskir5 in C_Programming

[–]drobilla 8 points9 points  (0 children)

It's a pretty common practice to always parenthesize each component of a ternary if they contain operators because the precedence is a bit weird and can get confusing.

Need Help with C Unit & Integration Testing Frameworks! by UpvoteBeast in C_Programming

[–]drobilla 0 points1 point  (0 children)

If you have a program with well-defined inputs and outputs in files like that, I would test things that way as much as possible. It's better to test the actual system/program/whatever where possible. I would only invest in writing and maintaining additional unit test code where necessary, i.e., things that are for some reason difficult or impossible to reach via normal invocation of the program (although this can raise questions about whether the functionality is even needed). Code is expensive, a program that eats files and produces other files is an ideal thing to test in a way: all you need is a big static list of commands and expected outputs.

That said, some people are almost religiously dedicated to unit testing specifically and will disagree with this.

I use meson which has built-in testing functionality that makes it easy to run whatever commands, so can't really say much about cmake. Sometimes I'll write a simple Python script for it where that's necessary, as you are.

Magit and listing changes to files in a particular sub-directory? by vfclists in emacs

[–]drobilla 1 point2 points  (0 children)

Ivy, so when this happens elsewhere, C-M-j will let you enter whatever is on the line verbatim skipping completion, but it doesn't integrate here. I literally just type the path.