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[] = ".ML_devel.djgpp@delorie_com.2007-04";
const char delimiter[] = ".";
char *result, *cp;
cp = strdupa(directory);
result = strtok(cp, delimiter);
printf("Result level 1 = %s\n", result);
result = strtok(NULL, delimiter);
printf("Result level 2 = %s\n", result);
result = strtok(NULL, delimiter);
printf("Result level 3 = %s\n", result);
result = strtok(NULL, delimiter);
printf("Result level 5 = %s\n", result);
return 0;
}
----8<------------------------------------------------------------------
but while compiling it with:
$ gcc -Wall -I/usr/include -o z_test z_test.c
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)
From the glibc documentation:
----[ "/usr/share/doc/glibc-doc/html/libc_5.html" ]---------------------
#include <paths.h>
#include <string.h>
#include <stdio.h>
const char path[] = _PATH_STDPATH;
int
main (void)
{
char *wr_path = strdupa (path);
char *cp = strtok (wr_path, ":");
while (cp != NULL)
{
puts (cp);
cp = strtok (NULL, ":");
}
return 0;
}
----8<------------------------------------------------------------------
Greetings
Michelle Konzack
sitting on the line...
--
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)
> $ gcc -Wall -I/usr/include -o z_test z_test.c
> 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?
DJGPP 2.03 or 2.04 does not have strdupa(). You need an updated Glibc.
--
Robert Riebisch
Bitte NUR in der Newsgroup antworten!
Please reply to the Newsgroup ONLY!
Hmmm, so it is NOT portable (Dos->Linux)...
Then I need another function. Grrr!
Greetings
Michelle Konzack
> Hmmm, so it is NOT portable (Dos->Linux)...
It is portable. Just a matter of efforts.