home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sun.misc:3976 comp.lang.c:12896
- Newsgroups: comp.sys.sun.misc,comp.lang.c
- Path: sparky!uunet!mcsun!fuug!kiae!relcom!news-server
- From: Leonid A. Broukhis <leo@ipmce.su>
- Subject: Strange error in C compiler
- Message-ID: <13271.714953297@kiae.su>
- Keywords: dynamic linking C compilation constant pointer
- Lines: 34
- Sender: news-server@kiae.su
- Reply-To: leo@ipmce.su
- Organization: unknown
- Date: Thu, 27 Aug 1992 21:42:27 +0400
-
- Hello all!
-
- Consider the following code:
-
- /*
- _DYNAMIC is linker-defined and may be either 0 or non-zero,
- depending on link mode.
- */
-
- extern _DYNAMIC[];
-
- main() {
- if (_DYNAMIC)
- puts("Dynamic");
- else
- puts("Static");
- }
-
- The above code doesn't work, but with if-statement rewritten
- as follows does:
-
- if (_DYNAMIC != (int*) 0)
-
- Could anyone explain why?
-
- Note: in the first case compiler treats else-clause as dead
- code, but in the second one everything is compiled as
- expected.
-
- Regards,
- --
- Leonid A. Broukhis
-
-
-