home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 241,703 of 243,242   
   Keith Thompson to Richard Tobin   
   Re: New and improved version of cdecl   
   30 Oct 25 13:21:39   
   
   From: Keith.S.Thompson+u@gmail.com   
      
   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 */   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca