9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] APE: strdup()
@ 2001-10-15  7:14 pac
  2001-10-15  7:22 ` Boyd Roberts
  2001-10-15  7:41 ` Wladimir Mutel
  0 siblings, 2 replies; 8+ messages in thread
From: pac @ 2001-10-15  7:14 UTC (permalink / raw)
  To: 9fans

     char *parameterfile, optarg;
		...
     parameterfile = strdup(optarg);

cc: incompatible types: "IND CHAR" and "INT" for op "AS"
although manpage says:
char* strdup(char *s)


--
Peter A Cejchan
biologist
Acad. Sci., Prague, CZ
<cej at cejchan dot gli dot cas dot cz>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] APE: strdup()
  2001-10-15  7:14 [9fans] APE: strdup() pac
@ 2001-10-15  7:22 ` Boyd Roberts
  2001-10-15  7:41 ` Wladimir Mutel
  1 sibling, 0 replies; 8+ messages in thread
From: Boyd Roberts @ 2001-10-15  7:22 UTC (permalink / raw)
  To: 9fans

pac wrote:
> 
>      char *parameterfile, optarg;
>                 ...
>      parameterfile = strdup(optarg);
> 
> cc: incompatible types: "IND CHAR" and "INT" for op "AS"
> although manpage says:
> char* strdup(char *s)

Yes, this is why I don't like declarations like that.

You have declared a char * [parameterfile] and a char [optarg]
which has be premoted to int when passed to strdup().

Before I shoot myself in the foot, I checked out getopt(3).

You need to declare:

    extern char *optarg;

I never commit to memory all this quirky stuff;  I always use man.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] APE: strdup()
  2001-10-15  7:14 [9fans] APE: strdup() pac
  2001-10-15  7:22 ` Boyd Roberts
@ 2001-10-15  7:41 ` Wladimir Mutel
  2001-10-15  7:47   ` Boyd Roberts
  1 sibling, 1 reply; 8+ messages in thread
From: Wladimir Mutel @ 2001-10-15  7:41 UTC (permalink / raw)
  To: 9fans

In article <cej-1011015091415.A01300@cejchan.gli.cas.cz> you wrote:
>     char *parameterfile, optarg;
>                ...
>     parameterfile = strdup(optarg);

> cc: incompatible types: "IND CHAR" and "INT" for op "AS"
> although manpage says:
> char* strdup(char *s)

	Write this way :

	char * p, * o;

	In your case, you get optarg of type char, not char *.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] APE: strdup()
  2001-10-15  7:41 ` Wladimir Mutel
@ 2001-10-15  7:47   ` Boyd Roberts
  2001-10-15 10:01     ` strdup once more, was: " pac
  0 siblings, 1 reply; 8+ messages in thread
From: Boyd Roberts @ 2001-10-15  7:47 UTC (permalink / raw)
  To: 9fans

Wladimir Mutel wrote:
>         Write this way :
> 
>         char * p, * o;

No, the spaces make it look like a binary operator.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* strdup once more, was: Re: [9fans] APE: strdup()
  2001-10-15  7:47   ` Boyd Roberts
@ 2001-10-15 10:01     ` pac
  2001-10-22  9:25       ` Douglas A. Gwyn
  0 siblings, 1 reply; 8+ messages in thread
From: pac @ 2001-10-15 10:01 UTC (permalink / raw)
  To: 9fans


oooops, I made a typo when reporting error;
actually, the declarations were okay, as you advised:


	char *parameterfile = NULL;
	extern char *optarg;
		...

The problem persists. Apologies to all involved!

-pac-



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: strdup once more, was: Re: [9fans] APE: strdup()
  2001-10-15 10:01     ` strdup once more, was: " pac
@ 2001-10-22  9:25       ` Douglas A. Gwyn
  0 siblings, 0 replies; 8+ messages in thread
From: Douglas A. Gwyn @ 2001-10-22  9:25 UTC (permalink / raw)
  To: 9fans

pac wrote:
> The problem persists.
You need a (correct) declaration of strdup in scope when it is called.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: strdup once more, was: Re: [9fans] APE: strdup()
  2001-10-15 10:37 forsyth
@ 2001-10-22  9:26 ` Douglas A. Gwyn
  0 siblings, 0 replies; 8+ messages in thread
From: Douglas A. Gwyn @ 2001-10-22  9:26 UTC (permalink / raw)
  To: 9fans

forsyth@vitanuova.com wrote:
> strdup is in the bsd.h extensions (along with getopt).
> perhaps it wasn't or isn't ANSI; ...

Yes, or is it no, strdup is not a Standard C function.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: strdup once more, was: Re: [9fans] APE: strdup()
@ 2001-10-15 10:37 forsyth
  2001-10-22  9:26 ` Douglas A. Gwyn
  0 siblings, 1 reply; 8+ messages in thread
From: forsyth @ 2001-10-15 10:37 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 135 bytes --]

strdup is in the bsd.h extensions (along with getopt).
perhaps it wasn't or isn't ANSI; at any rate, that's what APE thinks of it.


[-- Attachment #2: Type: message/rfc822, Size: 1663 bytes --]

To: 9fans@cse.psu.edu
Subject: strdup once more, was: Re: [9fans] APE: strdup()
Date: Mon, 15 Oct 2001 12:01:26 +0200
Message-ID: <cej-1011015120126.A071032@cejchan.gli.cas.cz>


oooops, I made a typo when reporting error;
actually, the declarations were okay, as you advised:


	char *parameterfile = NULL;
	extern char *optarg;
		...

The problem persists. Apologies to all involved!

-pac-

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-10-22  9:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-15  7:14 [9fans] APE: strdup() pac
2001-10-15  7:22 ` Boyd Roberts
2001-10-15  7:41 ` Wladimir Mutel
2001-10-15  7:47   ` Boyd Roberts
2001-10-15 10:01     ` strdup once more, was: " pac
2001-10-22  9:25       ` Douglas A. Gwyn
2001-10-15 10:37 forsyth
2001-10-22  9:26 ` Douglas A. Gwyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).