今天看到一段程序 里面有这样一段
就在main的开头
#if !LIBRARY
#include "includes.h"
#include <sys/ioctl.h>
#include <termios.h>
我的疑问是1. #if !LIBRARY 到底是什么意思 我们一般都不会加感叹号的 .
2.我不知道他在那里定义的LIBRARY.
请高手指点
[问题] !LIBRARY
- s4426565
- 帖子: 34
- 注册时间: 2007-10-24 1:37
- nobrain
- 帖子: 808
- 注册时间: 2005-08-25 13:58
- 来自: ustc
- 联系:
-
- 帖子: 156
- 注册时间: 2007-09-05 1:09
- 来自: beijing
- nobrain
- 帖子: 808
- 注册时间: 2005-08-25 13:58
- 来自: ustc
- 联系:
- s4426565
- 帖子: 34
- 注册时间: 2007-10-24 1:37
nobrain 写了:这个宏不一定要在文件里定义。一般条件预处理相关的宏在 Makefile 里定义,来控制编译不同的版本
gcc 的 -D 参数后面就可以指定要定义的宏
我检查了makefile 里的定义 真的没有 #define LIBRARY 之类的语句
makefile 如下:
# Makefile for compiling, testing, and installing Mathomatic under any UNIX like OS.
# Currently uses gcc only options in CFLAGS, just remove them for other C compilers.
VERSION = `cat VERSION`
CFLAGS += -Wuninitialized -Wshadow -Wformat -Wparentheses -Wcast-align # gcc specific flags
CFLAGS += -O -DUNIX -DVERSION="$(VERSION)" # general cc flags
LDFLAGS += # The default linker flags.
LIBS += -lm # The default libraries to link.
# "make READLINE=1" to include readline support:
CFLAGS += $(READLINE:1=-DREADLINE)
LIBS += $(READLINE:1=-lreadline -lncurses)
# Install directories:
prefix ?= /usr/local
bindir ?= $(prefix)/bin
mandir ?= $(prefix)/man
docdir ?= $(prefix)/share/doc
DOC = doc/mathomatic.1.html doc/matho-primes.1.html doc/matho-pascal.1.html doc/matho-sumsq.1.html
AOUT = mathomatic # The name of the executable to create.
OBJECTS = main.o globals.o am.o solve.o help.o parse.o cmds.o simplify.o \
factor.o super.o unfactor.o poly.o diff.o integrate.o \
complex.o complex_lib.o list.o 囗囗囗.o factor_int.o
MAN1 = mathomatic.1
DOCS = VERSION AUTHORS COPYING README.txt changes.txt mathomatic.ico
all: $(AOUT) $(DOC) # make these by default
@echo Make completed.
doc: $(DOC)
check test:
@echo Testing Mathomatic...
@cd tests && time ../$(AOUT) -t all 0<&- >test.out && diff -u all.out test.out
@rm tests/test.out
@echo All tests passed.
baseline:
@cd tests && ../$(AOUT) -t all 0<&- >all.out
@rm -f tests/test.out
@echo File tests/all.out updated with current test output.
$(OBJECTS): includes.h am.h externs.h complex.h proto.h VERSION
$(AOUT): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(AOUT)
# Here we convert the man pages to HTML docs:
doc/mathomatic.1.html: mathomatic.1
rman -f HTML mathomatic.1 >doc/mathomatic.1.html
doc/matho-primes.1.html: primes/matho-primes.1
rman -f HTML primes/matho-primes.1 >doc/matho-primes.1.html
doc/matho-pascal.1.html: primes/matho-pascal.1
rman -f HTML primes/matho-pascal.1 >doc/matho-pascal.1.html
doc/matho-sumsq.1.html: primes/matho-sumsq.1
rman -f HTML primes/matho-sumsq.1 >doc/matho-sumsq.1.html
install:
install -d $(bindir)
install -d $(mandir)/man1
install -d $(docdir)/mathomatic
install -d $(docdir)/mathomatic/html
install -d $(docdir)/mathomatic/m4
install -d $(docdir)/mathomatic/tests
install -d $(docdir)/mathomatic/factorial
install -d $(prefix)/share/applications
install -d $(prefix)/share/pixmaps
install -m 0755 $(AOUT) $(bindir)
install -m 0644 $(MAN1) $(mandir)/man1
install -m 0644 $(DOCS) $(docdir)/mathomatic
install -m 0644 doc/* $(docdir)/mathomatic/html
install -m 0644 m4/* $(docdir)/mathomatic/m4
install -m 0644 tests/* $(docdir)/mathomatic/tests
install -m 0644 factorial/* $(docdir)/mathomatic/factorial
install -m 0644 mathomatic.desktop $(prefix)/share/applications
install -m 0644 mathomatic.png $(prefix)/share/pixmaps
@echo Install completed.
uninstall:
rm -f $(bindir)/$(AOUT)
cd $(mandir)/man1 && rm -f $(MAN1)
rm -rf $(docdir)/mathomatic
rm -f $(prefix)/share/applications/mathomatic.desktop
rm -f $(prefix)/share/pixmaps/mathomatic.png
@echo Uninstall completed.
clean:
rm -f *.o *.a
rm -f lib/*.o lib/*.a
flush: clean
rm -f $(AOUT)
rm -f mathomatic_secure
- s4426565
- 帖子: 34
- 注册时间: 2007-10-24 1:37
- nobrain
- 帖子: 808
- 注册时间: 2005-08-25 13:58
- 来自: ustc
- 联系: