@tubetime I miss #ifdef... What a great way to knock out a 💩 ton of code.
Small success today - my Cinepak player can now auto-detect AVI and Quicktime (mov) files and play videos from either. Still some things to fix, but it's coming along. The lite/low-memory version is enabled with an #ifdef. I'm thinking of making this a runtime choice, but it creates some challenges.
lib/libc/gen: pthread_atfork.c
lib/libc/softfloat: softfloat-specialize
riastradh: libc: Sprinkle #ifdef _REENTRANT around thr_sigsetmask.
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/gen/pthread_atfork.c.diff?r1=1.27&r2=1.28
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/softfloat/softfloat-specialize.diff?r1=1.10&r2=1.11
(Possibly relevant to @b0rk 's interests)
So I hit a flag in diff, --unchanged-group-format
. It does not show up in the manpage. It does not show up in --help. You can search both those channels for that string and you will not find it.
You know where it shows up first? If you Google it, you'll get an example in https://www.gnu.org/software/diffutils/manual/html_node/Line-Group-Formats.html.
So why doesn't it show up in the manpage? Well, it does! If you read the entire manpage. With your eyes.
-D, --ifdef=NAME output merged file with '#ifdef NAME' diffs
--GTYPE-group-format=GFMT format GTYPE input groups with GFMT
--line-format=LFMT format all input lines with LFMT
--LTYPE-line-format=LFMT format LTYPE input lines with LFMT
These format options provide fine-grained control over the output
of diff, generalizing -D/--ifdef.
LTYPE is 'old', 'new', or 'unchanged'. GTYPE is LTYPE or 'changed'.
"What do you mean it isn't documented? Of course it's documented. You did read every line and do some template-substitution in your brain, didn't you?"
This isn't advocating for not reading the manpage. If you really want to understand how the tool works, you read the whole manpage. And probably the source code. 😉
... but I don't want to understand how the tool works. I want to diff two files and not have the lines that are the same get emitted.
And I think a lot of application- and solution-generating computer people, most of the time, in most of their careers, are operating on that level of depth. Problems come in too fast and with too much variety. You absolutely go deep on some things. There is no time to go deep on everything.
So how do we address this (other than throw up our hands and say "Relying on Google's fuzzy search of the whole Internet and vibe-coding LLMs is the future actually")? I don't have magic bullets, but a "fuzzy search" mode in something like less
that could take an input like --unchanged-group-format
and twig that it if there's no exact match, it might be related to --GTYPE-group-format
would be nice.
Maybe I should mock that up in emacs. Actually, I bet someone already put it in emacs. ;)
うーん。FreeDV-GUI、sioclientが無いことを想定していない作りになっているのでsioclient抜きのビルドをしたいとなるとかなり大掛かりな修正が必要になりそう。
(#ifdef~#endifで切るよりは、ダミーに置き換えたコードを作った方が良いのかも)
static const struct memdev {
const char *name;
const struct file_operations *fops;
fmode_t fmode;
umode_t mode;
} devlist[] = {
#ifdef CONFIG_DEVMEM
[DEVMEM_MINOR] = { "mem", &mem_fops, 0, 0 },
#endif
[3] = { "null", &null_fops, FMODE_NOWAIT, 0666 },
#ifdef CONFIG_DEVPORT
[4] = { "port", &port_fops, 0, 0 },
#endif
[5] = { "zero", &zero_fops, FMODE_NOWAIT, 0666 },
[7] = { "full", &full_fops, 0, 0666 },
[8] = { "random", &random_fops, FMODE_NOWAIT, 0666 },
[9] = { "urandom", &urandom_fops, FMODE_NOWAIT, 0666 },
#ifdef CONFIG_PRINTK
[11] = { "kmsg", &kmsg_fops, 0, 0644 },
#endif
};
#ifdef CONFIG_PROC_FS
void chrdev_show(struct seq_file *f, off_t offset)
{
struct char_device_struct *cd;
mutex_lock(&chrdevs_lock);
for (cd = chrdevs[major_to_index(offset)]; cd; cd = cd->next) {
if (cd->major == offset)
seq_printf(f, "%3d %s\n", cd->major, cd->name);
}
mutex_unlock(&chrdevs_lock);
}
#endif /* CONFIG_PROC_FS */
fs/char_dev.c
This is evil. Evil. Just evil. Why Linus oh why why why why why did you merge this code 19 years ago
@siguza @fay59 Yes. If you're not just going to infinitely backport this, you need #ifdef
perhaps combined with __asm__("...")
. The standard version of that is Transparent Aliases ( https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Transparent%20Aliases.html ) which is being worked on for C2y.
But you don't have to use __STDC_VERSION__
specifically: rather than ask the compiler, you ask the header using the C23-introduced __STDC_STDIO_H_VERSION__
header macro. The library controls that macro, so if the library says it's at <stdio.h>
for C2y, it had better implement a C2y formatter like it's promising. That's how the compiler can check if it REALLY wanted to. Or, both versions get baked into the e.g. the format
attribute and it's up to the library vendor to select which version they care about.
There are many ways to skin this cat. Implementations have been doing this since time immemorial (see _DARWIN_ALIAS(...)
and other shenanigans).
@mikeymikey @kickingvegas @siracusa is that an #ifdef in a shell script? What?
In one file in the CnC Red Alert source, there's an #ifdef TIBERIAN_SUN and that had me really excited for a moment.
@imperio I knew so many people using FreeBSD and no one really complaint before. I personally don't use it (have it on my old NAS), but reasons are historical/technical.
I think BSD operates in a old model of `autoconf` probing API features and adjusting by tons of `#ifdef`, what obviously doesn't play well with #Rust.
Вот почему Сишные директивы надо писать с начала строки по многим кодстайлам.
Как по мне любой if приятнее читать если его тело оттабулированно и его можно без проблем воспринять визуально, не вдумываясь сознательно где начало, а где конец.
Даже если это #ifdef, кажется что так удобнее.
Хотя ясен аргумент, что это выделяет данные блоки кода и сразу форсит обратить внимание на то что ЭТИМ занимается препроцессор.
Может такие правила кодстайла это рудименты во времена без подсветки синтаксиса?
@jackwilliambell The only time I use a separate directory for includes is if I have an include file that's specific to a certain platform. Sometimes, instead of using #ifdef for each platform in a header file, I create an include file with the same name for each platform and put them in their own directories. It depends on how platform specific the code is and what's more readable for the specific case.
@amsomniac c programmers posting here know about the #ifdef
hashtag