ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2007/05/11/14:17:39

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Fri, 11 May 2007 20:12:39 +0200
From: Michelle Konzack <dos4michelle AT freenet DOT de>
To: djgpp <djgpp AT delorie DOT com>
Subject: undefined reference to `strdupa'
Message-ID: <20070511181239.GV3209@freenet.de>
Mime-Version: 1.0
X-Message-Flag: Improper configuration of Outlook is a breeding ground for viruses. Please take care your Client is configured correctly. Greetings Michelle.
X-Disclaimer-DE: Eine weitere Verwendung oder die Veroeffentlichung dieser Mail oder dieser Mailadresse ist nur mit der Einwilligung des Autors gestattet.
Organisation: Michelle's Selbstgebrautes
X-Operating-System: Linux devel.private 2.4.27-2-386
X-Uptime: 13:34:56 up 13 days, 17:05, 11 users, load average: 0.21, 0.16, 0.10
X-Homepage-4: http://freenet-homepage.de/dos4michelle/
User-Agent: Mutt/1.5.9i
Reply-To: djgpp AT delorie DOT com

--A47bNRIYjYQgpFVi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello,

I have a simpel test program which schould split a Courier-Maildir in
its levels using:

----8<------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <stddef.h>

int main(int argc, char *argv[])
{
  const char directory[] =3D ".ML_devel DOT djgpp AT delorie_com DOT 2007-04";
  const char delimiter[] =3D ".";
  char *result, *cp;

  cp =3D strdupa(directory);
 =20
  result =3D strtok(cp, delimiter);
  printf("Result level 1 =3D %s\n", result);

  result =3D strtok(NULL, delimiter);
  printf("Result level 2 =3D %s\n", result);

  result =3D strtok(NULL, delimiter);
  printf("Result level 3 =3D %s\n", result);

  result =3D strtok(NULL, delimiter);
  printf("Result level 5 =3D %s\n", result);

  return 0;
}
----8<------------------------------------------------------------------

but while compiling it with:

$ gcc -Wall -I/usr/include -o z_test z_test.c=20
z_test.c: In function 'main':
z_test.c:11: warning: implicit declaration of function 'strdupa'
z_test.c:11: warning: assignment makes pointer from integer without a cast
/tmp/michelle.konzack.r23246/ccSIU3aN.o: In function `main':
z_test.c:(.text+0x37): undefined reference to `strdupa'
collect2: ld returned 1 exit status

which is the first time I see this error.  --  WHY?

Oh, I have this and other examples from a GNU-C Book and they are many
which are not working.  (even with the provided original exanple files)

=46rom the glibc documentation:

----[ "/usr/share/doc/glibc-doc/html/libc_5.html" ]---------------------
#include <paths.h>
#include <string.h>
#include <stdio.h>

const char path[] =3D _PATH_STDPATH;

int
main (void)
{
  char *wr_path =3D strdupa (path);
  char *cp =3D strtok (wr_path, ":");

  while (cp !=3D NULL)
    {
      puts (cp);
      cp =3D strtok (NULL, ":");
    }
  return 0;
}
----8<------------------------------------------------------------------

Greetings
    Michelle Konzack
    sitting on the line...

--=20
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSN LinuxMichi
0033/6/61925193    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

--A47bNRIYjYQgpFVi
Content-Type: application/pgp-signature; name="signature.pgp"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFGRLIWXnHp6ejAnVoRAjqVAJ0dhGh6NtDHN4W2nVoVdYg6B4jgnwCeLyDJ
jg3ta6nW9/Mcfl43bpF6abc=
=hioz
-----END PGP SIGNATURE-----

--A47bNRIYjYQgpFVi--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019