floof.org

Simon Tatham • mastodon (AP)

Thanks, g++.

I just absentmindedly wrote a two-argument assert statement in C++, because I've got too used to languages like Rust and Python which let you give a reason for the assertion as a separate string argument.

g++ reported two errors:

1. assert only takes one argument! Look at the definition here in <cassert>.

2. The preprocessor output contains a reference to the identifier 'assert', which should have been expanded as a macro. Perhaps you should consider including <cassert>? Look, you can put the include statement here near the top of your source file, right after the include of <cassert>.

dmiException 🎃 • akkoma (AP)

I’ve had this exact problem with the preprocessor being absolutely lost in its tracks and suggesting to add an include right below the same include. infuriating, i don’t remember how I fixed it…

sidenote: love your window decorations, $PS1 and font choice :)

Simon Tatham • mastodon (AP)
@domi and, in fairness, it's not only g++, or C++, which causes this kind of confusion. Figuring out the best error report when something goes wrong and there's a separate macro preprocessor involved is always hard. I've also had rustc suggest that I rewrite a perfectly sensible #[derive(PartialEq)] as the totally incoherent #[derive(PartialEq.into())]!
Esteban Küber :rust: • mastodon (AP)
@domi FWIW, the rustc one is considered a bug, it just requires significant effort to fix it in a general way ^_^'
Simon Tatham • mastodon (AP)

@domi re sidenote: thank you!

The window decorations are the 'Crux' theme from the Sawfish window manager, which I mostly use for its programmability rather than its looks (although I agree Crux is pretty nice).

The font is my own work, on my website but still in "unfinished" status: https://www.chiark.greenend.org.uk/~sgtatham/technicality/

The choice of PS1 is designed so that it turns into a no-op shell statement, so that I can copy-paste a whole line from one terminal to another without having to carefully not select the prompt at the start. It's coloured using something that isn't one of the standard 8 ANSI colours so as to be easily distinguishable from _most_ other terminal output, in the expectation that most things will stick to the usual 8.

(ok, and also because purple is cool)

1
Tom Hayward • mastodon (AP)

@domi

That's a really good idea. I like it!

dmiException 🎃 • akkoma (AP)

this is a lot more lore than I expected! thank you for sharing!

may I ask how you made the scalable version of the font? I’ve played with FontForge before, but it was always a quite painful experience - do you know of anything better that can output a TTF or similar?

(sorry if you answered this in your post, I read through it and I can’t find the software package mentioned anywhere)

Simon Tatham • mastodon (AP)

the source code of the Technicality font is in Metafont, so it's not drawn in a WYSIWYG graphical package at all – it looks more like a computer program. An example is shown in the screenshot at the top of the page.

Metafont natively renders from that kind of source code to a large bitmap, so I have a fairly horrible build pipeline that takes that bitmap, feeds it through 'potrace' to get a Postscript-style outline of the filled area, and converts that into a font using the Fontforge Python API. Hints are specified in the Metafont code by functions that print them on mf's standard output, and my build script picks those up and adds them to the font file it's building.

For previewing while I'm actually designing a glyph, I have a build tool that renders to a Postscript file I can load in gv, containing the glyph outline and also labelling all the points I defined identifiers for in the source code, so that it's easy to look at the picture and see which point needs to be tweaked. But I don't get to interactively drag the point around until it's just right – every tweak is a matter of adjusting a number in the code and re-running the previewer. So I think you might still consider this to fall into your category of "a quite painful experience" :-)

The main reason I did it that way is so I can re-render the same glyph shapes in fixed and variable width, and also bold and normal weight (and I hope oblique at some future point) with the essential shapes staying the same and I don't have to put in 4× the manual effort per character. Also it makes it convenient to reuse subroutines or entire characters in other contexts, like accented characters (reusing a in á, etc) or fractions (reusing 1 and 2 in ½).

This entry was edited (1 year ago)
1
Mercutio • mastodon (AP)
The error messages sound like typical LLM slop. Disgusting!
Simon Tatham • mastodon (AP)
@Mercutio I say, steady on! This is surely good old-fashioned _conventional_ confused error message generation. gcc seems like the last project that would shovel an LLM into a perfectly good tool for no reason.

@Mercutio It is definitely not LLM based slop.
The underlying issue was already filed as https://gcc.gnu.org/PR102846 already (filed 4 years ago).

Basically the problem for assert is a preprocessed function macro but the diagnostic is only looked up using the C/C++ identifiers and not into preprocessor identifiers (which is a different lookup).

assert is the only one this happens with. Due to the preprocessor confusion. I have not looked into seeing how easy to fix this issue is though (it might be easy to fix as you lookup assert as a macro to see if it is defined or not; libcpp might have that interface [or not]).