The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: mysterious #define
Celtik
Newbie
Rank: 1



UID 84
Digest Posts 0
Credits 0
Posts 62
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 15, 2007 08:07 AM  Profile | P.M. 
mysterious #define



mysterious #define



in the header file orville.h, outside of the #ifdef #endif , there is the following

#define job_control /* support job-control */

as you can see, the job_control macro has no value associated with it. here is what i go when i ran grep on the entire source code.

[cda@localhost orville-write-2.55]$ grep -ir job_control ~/orville-write-2.55
/home/cda/orville-write-2.55/orville.h:#define job_control /* support job-control */

/home/cda/orville-write-2.55/wrt_sig.c:#ifdef job_control
/home/cda/orville-write-2.55/wrt_sig.c:#endif /*job_control*/
/home/cda/orville-write-2.55/wrt_sig.c:#ifdef job_control
/home/cda/orville-write-2.55/wrt_sig.c:#endif /*job_control*/
/home/cda/orville-write-2.55/wrt_sig.c:#ifdef job_control
/home/cda/orville-write-2.55/wrt_sig.c:#endif /*job_control*/

in, wrt_sig.c, there is only stuff like this
/* siginit -- set up the signal handler routines.
*/

void siginit()
{
signal(sigterm,(retsigtype (*)())intr);
signal(sigint,(retsigtype (*)())intr);
signal(sighup,(retsigtype (*)())intr);
#ifdef job_control
signal(sigtstp,(retsigtype (*)())susp);
#endif /*job_control*/

}

/* sigoff -- turn off all signals the signal handler routines.
*/

void sigoff()
{
signal(sigint,sig_ign);
signal(sigquit,sig_ign);
signal(sigterm,sig_ign);
#ifdef job_control
signal(sigtstp,sig_ign);
#endif /*job_control*/
}

so does the os just assign some value to job_control?


Top
dely^gun
Newbie
Rank: 1



UID 112
Digest Posts 0
Credits 0
Posts 62
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 15, 2007 08:07 AM  Profile | P.M. 
quote:
originally posted by frequency8
that response reminds me of the day i decided i wasn't cut out to be a math major. in my linear algebra class, my professor said "there is something in the vector space. that something is nothingness."

okay, so now, let me get this right.

when i go
#define something

something is being defined, but we aren't too sure what that something is? and then later on, when i see

#ifdef job_control
signal(sigtstp,(retsigtype (*)())susp);
#endif /*job_control*/

we can use that something, which aren't too sure of what it is, to test to see if the shell supports job control?



never mind. i looked over the code again and thought about it. what you said just sank in.
Top
DemonMaster
Newbie
Rank: 1



UID 114
Digest Posts 0
Credits 0
Posts 55
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 15, 2007 08:07 AM  Profile | P.M. 
#define is an old part of c.

code:

int i;

i is defined as an integer here. it's value is unspecified, which is a bad idea for variables by the way.


code:

#define i
i is defined but the value is unspecified. the difference here is that #define merely defines something that is a unique series of characters. it has no real meaning.
int i; has more meaning for humans, because integers are a class.
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:32 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005819 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP