Path: csiph.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: New and improved version of cdecl Date: Thu, 30 Oct 2025 13:21:39 -0700 Organization: None to speak of Lines: 57 Message-ID: <87v7jw5eek.fsf@example.invalid> References: <87bjlyobts.fsf@example.invalid> <10dumia$3uier$1@paganini.bofh.team> <87zf995859.fsf@example.invalid> <10dv52b$3gq3j$1@dont-email.me> <10e03jt$19ka6$1@artemis.inf.ed.ac.uk> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Thu, 30 Oct 2025 20:21:40 +0000 (UTC) Injection-Info: dont-email.me; posting-host="5554a9fe3bce56cb13705adf58e3063f"; logging-data="4176866"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Y8R0D3oGX9CboC6IDy6DJ" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:N53tqqV9hl31QmXynID6xkfhLBk= sha1:HC8TUduGjLIZ7POAcaU8JjsuB8A= Xref: csiph.com comp.lang.c:394980 richard@cogsci.ed.ac.uk (Richard Tobin) writes: > In article <10dv52b$3gq3j$1@dont-email.me>, > Richard Heathfield wrote: > >>$time make -j $(nproc) > > Eww. How does make distinguish between j with an argument and > j with no argument and a target? > > $ make -j a > make: *** No rule to make target 'a'. Stop. > $ make -j 3 > make: *** No targets specified and no makefile found. Stop. > $ make 3 > cc 3.c -o 3 > > That's a really bad idea. Meh. The data structure that defines the '-j' option in the GNU make source is: static struct command_switch switches[] = { // ... { 'j', positive_int, &arg_job_slots, 1, 1, 0, 0, &inf_jobs, &default_job_slots, "jobs", 0 }, //... }; Yes, it's odd that "-j" may or may not be followed by an argument. The way it works is that if the following argument exists and is (a string representing) a positive integer, it's taken as "-j N", otherwise it's taken as just "-j". A make argument that's not an option is called a "target"; for example in "make -j 4 foo", "foo" is the target. A target whose name is a positive integer is rare enough that the potential ambiguity is almost never an issue. If it is, you can use the long form: "make --jobs" or "make --jobs=N". I think it would have been cleaner if the argument to "-j" had been mandatory, with an argument of "0", "-1", or "max" having some special meaning. But changing it could break existing scripts that invoke "make -j" (though as I've written elsethread, "make -j" can cause problems). It would also have been nice if the "make -j $(nproc)" functionality had been built into make. The existing behavior is a bit messy, but it works, and I've never run into any actual problems with the way the options are parsed. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */