From owner-freebsd-hackers Fri Oct 11 12:47: 2 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9BADF37B401; Fri, 11 Oct 2002 12:46:59 -0700 (PDT) Received: from hawk.mail.pas.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3511843E8A; Fri, 11 Oct 2002 12:46:59 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0005.cvx21-bradley.dialup.earthlink.net ([209.179.192.5] helo=mindspring.com) by hawk.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1805k7-0007DY-00; Fri, 11 Oct 2002 12:46:39 -0700 Message-ID: <3DA72A53.9D2D61E5@mindspring.com> Date: Fri, 11 Oct 2002 12:45:23 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bruce Evans Cc: Craig Rodrigues , freebsd-standards@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: Problem detecting POSIX symbolic constants References: <20021011183032.D12170-100000@gamplex.bde.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bruce Evans wrote: > > I know it's not fashionable to write code that's portable to > > compilers other than GCC, but even if FreeBSD is going to ignore > > portability for it's own source code, it's probably unreasonable > > to expect ACE to ignore portability for theirs. > > Undefined symbols being 0 in cpp in expressions was in early C compilers > if not the original one. Consult your archives for a posting 10-15 years > or so ago by dmr in comp.std.c about him checking this in his archives. You mean "in preprocessor expressions", of course. > > This can't be the case; specifically, the sysconf() test will > > only work at runtime, which means that the symbols had to be > > there and resolvable at link time. > > Symbols can be resolved at runtime using dlopen(), etc. They would only > actually be available on systems where sysconf() says that they are. You can't depend on people using the standard C library via dlopen, as opposed to, uh, "linking". If you are depending on this, then you don't need sysconf: if the symbol isn't in the library, that's an equally valid indicator, so if the symbol lookup fail on a library open on Windows, which does not have sysconf at all (for example), it would have to be treated as equivalent. In UNIX, the symbol would have to be there, because the preferred linking technology *says* it has to be there for the link to succeed, if the symbol is referenced. Again, it's a *lot* easier for the programmers to say "screw this!", and blow off the runtime code morphing. > > Uh, the 1990 standard, which allowed "#if" is only 12 years old. > > #if is in K&R1 (1978). According to my first edition "The C Programming Language": 12.3 Conditional compilation A compiler control line of the form #if constant-expression checks whether the constant expression (see section 15) evaluates to non-zero. ... 15 Constant expressions In several places C requires expressions which evaluate to a constant: after case, as array bounds, and in initializers. In the first two cases, the expression can involve only integer constants, character constants, and sizeof expressions, possibly connected by the binary operators + - * / % & | ^ << >> == != < > <= >= or by the unary operators - ~ or by the ternary operator ?: ...no "&&" or "||"... sorry. Also, "defined()" is not defined. I think you will find that "&&" and "||" in #if statements are later extensions. The value of undefined macros in preprocessor expressions being assumed to be zero is also not documented in the book. I would have to imagine that they were not considered constant expressions. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message