![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| More on CEP Maturity: Capability Versus Reliability | iBot | Complex Event Processing RSS News | 0 | 06-03-2008 02:50 AM |
| Seeing the screen output beyond the scroll capability for the last run command | bimukt | UNIX for Dummies Questions & Answers | 1 | 05-02-2008 01:22 AM |
| How do capability macros get named? | frequency8 | High Level Programming | 2 | 05-23-2007 03:50 AM |
| saving macros for VIM | yngwie | UNIX for Dummies Questions & Answers | 3 | 05-13-2007 09:26 PM |
| troff macros | tonyt | UNIX for Dummies Questions & Answers | 2 | 01-03-2002 05:13 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
One last question about capability macros
This might be poorly worded.
In the header file, I have #ifdef LOCK_FCNTL #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif #define LOCK(file) setlock(fileno(file), F_WRLCK); #define UNLOCK(file) setlock(fileno(file), F_UNLCK); #endif /* LOCK_FCNTL */ #ifdef LOCK_FLOCK #ifdef HAVE_SYS_FILE_H #include <sys/file.h> #endif #define LOCK(file) flock(fileno(file), LOCK_EX) #define UNLOCK(file) flock(fileno(file), LOCK_UN) #endif /* LOCK_FLOCK */ And in the file that has main(), I have #ifdef LOCK_FCNTL /* Helper function to do fcntl locks. */ void setlock(int fd, int type) { struct flock lk; lk.l_type= type; lk.l_whence= 0; lk.l_start= 0L; lk.l_len= 0L; fcntl(fd,F_SETLKW,&lk); } #endif /*LOCK_FCNTL*/ My current operating system supports both fcntl() and flock(). However, the macros for LOCK and UNLOCK seem to assume that the operating system supports either one or the other, but not both. When I compile and run the program, I get no errors. So the question is, what macro does the computer use? Will it just chose one at random? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
If a system has both then the order of #ifdef's in the code will determine which is used. |
|||
| Google The UNIX and Linux Forums |