tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] extern char **environ


From: Uwe Ohse
Subject: [Tinycc-devel] extern char **environ
Date: Fri, 7 Feb 2003 13:13:28 +0000

Hello,

the test program below compiles and links without any problems, but
fails to run properly when compiled and linked with tcc, since 
"extern char **environ" is initialized to NULL. The program works
if tcc is used as an interpreter.

I'm not sure about the reason, it may well be that the culprit is 
the dynamic linker or the mess glibc created with the versioned symbols,
and not tcc.


Test program:
  #include <stdio.h>
  extern char **__environ;
  extern char **environ;
  int main(void)
  {
    char **e;
    char *x;
    e=__environ;
    if (!e) puts("__environ is NULL");
    else puts("__environ OK");
  
    e=environ;
    if (!e) puts("environ is NULL");
    else puts("environ OK");
  
    fputs("getenv(HOME) is ", stdout);
    x=(char *)getenv("HOME");
    if (x) puts(x);
    else puts("unset");
    return 0;
  }
Output with gcc:
  __environ OK
  environ OK
  getenv(HOME) is /home/uwe
"nm |grep environ" of the gcc compiled code
  08049688 B __environ@@GLIBC_2.0
  08049688 V environ@@GLIBC_2.0
Output of tcc compiled code:
  __environ OK
  environ is NULL
  getenv(HOME) is /home/uwe
Output of the program if it's interpreted by tcc:
  __environ OK
  environ OK
  getenv(HOME) is /home/uwe
"nm |grep environ" of the tcc compiled code
           U __environ
           U environ

Linux ranan.ohse.de 2.4.19-gentoo-r9 #5 SMP Tue Sep 17 12:52:11 UTC 2002 i686 
AMD Athlon(tm) XP 1700+ AuthenticAMD GNU/Linux
glibc 2.3.1
gcc (GCC) 3.2.1 20021207 (Gentoo Linux 3.2.1-20021207)

Regards, Uwe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]