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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ 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; 7+ 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] 7+ messages in thread

* Re: [9fans] APE: strdup()
@ 2001-10-15 19:15 David Gordon Hogan
  0 siblings, 0 replies; 7+ messages in thread
From: David Gordon Hogan @ 2001-10-15 19:15 UTC (permalink / raw)
  To: 9fans

Wladimir Mutel <mwg@fluffy.isd.dp.ua> writes:
>	Write this way :
>
>	char * p, * o;

No.



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

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

Thread overview: 7+ 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 19:15 David Gordon Hogan

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).