[comp.lang.c] What the hell does this mean??

robert@nereid.jpl.nasa.gov (Robert Angelino) (03/08/91)

Hello fellow C programmers,
	I have a small problem:

	I keep getting this error 
		"spa_tclkutc.c", line 130: unacceptable operand of &
	
	on this line

		(void) sscanf(ptr,"%04d",&(primary.utc.dy));

	Does anyone know what this means, I'm at my frustration limit..

Thanks in advance.
-- 
    -     ------       -                              Robert Angelino
   | |   | ----  \    | |                             ms T-1704L
   | |   | |   \ |    | |                             4800 Oak Grove Drive
   | |   | | --  |    | |                             Pasadena, CA 91109
---| |   | | \__/     | |___                          robert@triton.jpl.nasa.gov
\____|et |_|ropulsion |_____\aboratory                (818) 354-9574

dave@cs.arizona.edu (Dave P. Schaumann) (03/08/91)

In article <6117@mahendo.Jpl.Nasa.Gov> robert@triton.JPL.NASA.GOV writes:
>Hello fellow C programmers,
>	I have a small problem:
>		"spa_tclkutc.c", line 130: unacceptable operand of &
>	on this line
>		(void) sscanf(ptr,"%04d",&(primary.utc.dy));

The first thing that comes to mind is that primary was declared as a
register variable.  This is the only circumstance I am aware of that
forbids use of the & operator.

-- 
Dave Schaumann | dave@cs.arizona.edu | Short .sig's rule!

willcr@bud.sos.ivy.isc.com (Will Crowder) (03/08/91)

In article <6117@mahendo.Jpl.Nasa.Gov>, robert@nereid.jpl.nasa.gov
(Robert Angelino) writes:

|> Hello fellow C programmers,
|> 	I have a small problem:
|> 
|> 	I keep getting this error 
|> 		"spa_tclkutc.c", line 130: unacceptable operand of &
|> 	
|> 	on this line
|> 
|> 		(void) sscanf(ptr,"%04d",&(primary.utc.dy));
|> 
|> 	Does anyone know what this means, I'm at my frustration limit..
|> 
|> Thanks in advance.

This usually indicates trying to take the address of a register variable.
In this case, that seems a little strange, given that you're taking the
address of a member of a struct which is a member of another struct.

Is there some "interesting" #defining or something going on?

(In the future, it would help if you would give more details regarding the
compiler, system, and data types involved.  In this case, the declaration
for primary.utc.dy is probably the key.)

Hope this helps,

Will

rearl@churchy.ai.mit.edu (Robert Earl) (03/08/91)

In article <1083@caslon.cs.arizona.edu> dave@cs.arizona.edu (Dave P. Schaumann) writes:

|   In article <6117@mahendo.Jpl.Nasa.Gov> robert@triton.JPL.NASA.GOV writes:
|   >Hello fellow C programmers,
|   >	I have a small problem:
|   >		"spa_tclkutc.c", line 130: unacceptable operand of &
|   >	on this line
|   >		(void) sscanf(ptr,"%04d",&(primary.utc.dy));
|
|   The first thing that comes to mind is that primary was declared as a
|   register variable.  This is the only circumstance I am aware of that
|   forbids use of the & operator.

If "dy" is a bitfield member of the struct, as in:

      struct foo {
	int dy : 5;
      };

you cannot take its address.


--robert earl

horne-scott@cs.yale.edu (Scott Horne) (03/08/91)

In article <1083@caslon.cs.arizona.edu> dave@cs.arizona.edu (Dave P. Schaumann) writes:
>
>The first thing that comes to mind is that primary was declared as a
>register variable.  This is the only circumstance I am aware of that
>forbids use of the & operator.

Don't forget bit fields.

					--Scott

-- 
Scott Horne                               ...!{harvard,cmcl2,decvax}!yale!horne
horne@cs.Yale.edu      SnailMail:  Box 7196 Yale Station, New Haven, CT   06520
203 436-1817                    Residence:  Rm 1817 Silliman College, Yale Univ
Uneasy lies the head that wears the _gao1 mao4zi_.

karln@uunet.uu.net (03/09/91)

In article <6117@mahendo.Jpl.Nasa.Gov> robert@triton.JPL.NASA.GOV writes:
>	I have a small problem:
>
>		(void) sscanf(ptr,"%04d",&(primary.utc.dy));
>
>	Does anyone know what this means, I'm at my frustration limit..

	If dy is an array, then the address (&) symbol should be omitted.

Otherwise there is not really enough info here to figure out what your problem
is.

Karl Nicholas
karln!karln@uunet.uu.net

ckp@grebyn.com (Checkpoint Technologies) (03/09/91)

In article <6117@mahendo.Jpl.Nasa.Gov> robert@triton.JPL.NASA.GOV writes:
>	I keep getting this error 
>		"spa_tclkutc.c", line 130: unacceptable operand of &
>	on this line
>		(void) sscanf(ptr,"%04d",&(primary.utc.dy));

Only thing I can think of, is if "dy" is a bit field. You cant make a
pointer to a bit field.
-- 
First comes the logo: C H E C K P O I N T  T E C H N O L O G I E S      / /  
                                                                    \\ / /    
Then, the disclaimer:  All expressed opinions are, indeed, opinions. \  / o
Now for the witty part:    I'm pink, therefore, I'm spam!             \/

gosciak@muondev.uucp (Doug Gosciak) (03/10/91)

In <6117@mahendo.Jpl.Nasa.Gov> robert@nereid.jpl.nasa.gov (Robert Angelino) writes:

>Hello fellow C programmers,
>	I have a small problem:

>	I keep getting this error 
>		"spa_tclkutc.c", line 130: unacceptable operand of &
>	
>	on this line

>		(void) sscanf(ptr,"%04d",&(primary.utc.dy));

>	Does anyone know what this means, I'm at my frustration limit..

>Thanks in advance.
>-- 
>    -     ------       -                              Robert Angelino
>   | |   | ----  \    | |                             ms T-1704L
>   | |   | |   \ |    | |                             4800 Oak Grove Drive
>   | |   | | --  |    | |                             Pasadena, CA 91109
>---| |   | | \__/     | |___                          robert@triton.jpl.nasa.gov
>\____|et |_|ropulsion |_____\aboratory                (818) 354-9574

Is it possible that primary.utc.dy is the name of an array and therefore
the correct systax would be more like &(primary.utc.dy[0]) ?


-- 
------------------------------------------------------------------------------
Snail: Doug R. Gosciak     Quote: Become the one    Net: gosciak@muondev.uucp
       3321 Wyoming SW            you dream you     GEnie: DGOSCIAK
       Wyoming, MI 49509          can be.           CI$: 72115,703

richard@iesd.auc.dk (Richard Flamsholt S0rensen) (03/12/91)

>>>>> On 7 Mar 91 22:43:16 GMT, Robert Angelino said:
Robert> 		"spa_tclkutc.c", line 130: unacceptable operand of &
Robert> 	on this line
Robert> 		(void) sscanf(ptr,"%04d",&(primary.utc.dy));

  Well, seems as if it very much depends on the type of primary.utc.dy
- only invalid args to & are rvalues, bitfields and registers. You
guys agree with me?

Dave Schaumann:
>[...] comes to mind is that primary was declared as a register variable.

Robert Earl:
>If "dy" is a bitfield member of the struct, [...]

Scott Horne:
>Don't forget bit fields.

Will Crowder:
>This usually indicates trying to take the address of a register variable.

Karl Nicholas:
>If dy is an array, then the address (&) symbol should be omitted.

Checkpoint Technologies:
>Only thing I can think of, is if "dy" is a bit field.

Doug R. Gosciak:
>Is it possible that primary.utc.dy is the name of an array and [...]

  Of course, we *could* ask Robert what type primary.utc.dy has. But
who would ever do that? It would be a total spoiler  ;-)






--
/Richard Flamsholt
richard@iesd.auc.dk