From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] PCC - #if From: "Russ Cox" Date: Fri, 4 May 2007 17:17:40 -0400 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20070504211742.0EB1E1E8C26@holo.morphisms.net> Topicbox-Message-UUID: 59c3eaea-ead2-11e9-9d60-3106f5b1d025 term% diff ../../../openldap-2.3.32/include/ac/time.h ../../include/ac 20c20 < #if defined(TIME_WITH_SYS_TIME) --- > #if TIME_WITH_SYS_TIME 23c23 < #elif defined(HAVE_SYS_TIME_H) --- > #elif HAVE_SYS_TIME_H The < version is always valid; the > version is often valid. After #define A 1 #define B 0 #define C /* nothing! */ #undef D These are like #if 1: #if defined(A) #if defined(B) #if defined(C) #if A These are like #if 0: #if defined(D) #if B #if D and this is invalid: #if C (The rule for variables appearing in #if is that macros expand and names that make it through macro expansion turn into zeros, so `#if D' is like `#if 0' but `#if C' is like `#if', which is missing an expression.) So if the config.h for this program has done, say, #define TIME_WITH_SYS_TIME 1 #define HAVE_SYS_TIME_H 1 then the two versions you have are equivalent, but if it has done #define TIME_WITH_SYS_TIME #define HAVE_SYS_TIME_H then only the #if defined(...) versions are valid C. The convention in autoconf etc. is to either #define X 1 or #undef X for each variable X. Russ