Compiler Error - help

R

ravi.sathyam

Hi,
so basically I define a struct as follows:
struct speechSegment {

float coeff_Array[10];
float period;
float energy;
};

struct speechSegment segment = { /*I fill this struct with info */};

and later on in my main(), I declare a static array called coef[10],
and basically try to assign each value of coef[10] to the corresponding
value of coeff_Array

for(i = 0; i < Cmpst; i++) {
coef = (int)(segment.coeff_Array); -----------> Getting
compiler error on this line
}

But when I try to compile I get a compiler error on the aforementioned
line.
The error says "error: expression must have pointer-to-object type"

Any help as to why I'm getting this error will be appreciated..
Thanks,
Ravi
 
R

ravi.sathyam

Also please note that coef is an array of ints, so thats why I
casted....just to let you guys know...but I don't think thats why the
error is being generated
Thanks,
Ravi
 
M

Michael Mair

Hi,
so basically I define a struct as follows:
struct speechSegment {

float coeff_Array[10];
float period;
float energy;
};

struct speechSegment segment = { /*I fill this struct with info */};

and later on in my main(), I declare a static array called coef[10],
and basically try to assign each value of coef[10] to the corresponding
value of coeff_Array

for(i = 0; i < Cmpst; i++) {
coef = (int)(segment.coeff_Array); -----------> Getting
compiler error on this line
}

But when I try to compile I get a compiler error on the aforementioned
line.
The error says "error: expression must have pointer-to-object type"

Any help as to why I'm getting this error will be appreciated..
Thanks,


Please provide a minimal example -- your description is essentially
useless:
The following

int main (void)
{
struct speechSegment {
float coeff_Array[10];
float period;
float energy;
} segment = { {-0.1F, 1.0E4F, 47.11F, 0.F, 0.F,
0.F, 0.F, 0.F, 0.F, 0.F},
3.141592654F, 0.0F};
int i;
static int coef[10];
for(i = 0; i < 10; i++) {
coef = segment.coeff_Array;
}

return 0;
}

compiles _and_ fits your description.

You probably declared coef in the wrong way.
Note that casting can mask errors; therefore, use as few casts
as possible. Here, casting is unnecessary and can be left out.

If you answer, please quote enough context -- not everyone
gets every message in the same order or at all.


Cheers
Michael
 
R

ravi.sathyam

Sorry - OK I guess I don't get this - why did you declare coef as
static?
Ravi
 
M

Michael Mair

I asked you explicitly to quote context. Why are you making
it harder for people to help you?
If you are using google and don't know how, search via
groups.google for Keith Thompson's signature on this topic.

Sorry - OK I guess I don't get this - why did you declare coef as
static?

You stated:
"and later on in my main(), I declare a static array called coef[10],"
So, I gave you a "static array 10 of int" called coef.
If you meant something different by "static array" within the
context of C, then say so.

-Michael
 
R

ravi.sathyam

Oh wow...ok see I was trying to understand what you meant by quoting
context...MY Mistake! - I had never declared a static array...I had
meant to say I declared allocated memory off the stack for
this...stack..not static..sorry...regardless it doesnt matter..I did'nt
mean to say that.

Hmm..regardless, even declaring coef as a static array doesnt solve the
compiler problem

Ravi
 
R

ravi.sathyam

I apologize for being confusing...but clarify on what you mean by
quoting context....I don't post here often so this will be good to know
Ravi
 
A

Artie Gold

I apologize for being confusing...but clarify on what you mean by
quoting context....I don't post here often so this will be good to know
Ravi
`Quoting context' means just that. In *your message* quote the relevant
part of the the message to which you are replying. Otherwise those of us
who use real newsreaders have no idea what you're talking about.

[Note: I have quoted your message above...see?]

HTH,
--ag
 
R

Rob Adams

Sorry - OK I guess I don't get this - why did you declare coef as
static?
Ravi

Ravi, please re-read Michael's response carefully. I'll highlight the
relevant portions:

"If you answer, please quote enough context." Please provide enough
context so that any particular message can be read by itself. Some
readers may have never seen your original post, nor Michael's response.
Some readers may have read those posts, but can no longer remember them
by the time they read your post. Please provide context in each and
every reply. Some newsreaders make this difficult, but not impossible.
If you are using Google Groups, for example, you have to perform special
magic to make this happen. The steps are described dozens of times per
day in this newsgroup alone.

"Please provide a minimal example." No one can debug your problem from
the incomplete data given in your original post, Michael's admirable
effort notwithstanding. please provide the smallest program you can that
still demonstrates your problem. Rather than make us guess which of the
ten million possible mistakes you might have made, we can tell you
precisely which one you did.

"The following ... fits your description." Your exchange so far reads
like this:
You: "I declare a static array called coef[10]".
Michael: "static int coef[10];".
You: "why did you declare coef as static?"
This precisely highlights why Michael wants to study your program,
instead of you studying his. We can't guess what is wrong with your
program from you inexact explanation. Only by pasting the exact program
that fails can we understand your problem.

I hope this helps. I look forward to seeing your response, with context,
and with a small program that demonstrates the error.

Rob
 
K

Keith Thompson

Michael Mair said:
I asked you explicitly to quote context. Why are you making
it harder for people to help you?
If you are using google and don't know how, search via
groups.google for Keith Thompson's signature on this topic.

It's not actually my signature; it's something I wrote that others
have used as their signatures.

Here it is:

If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
 
D

Default User

I apologize for being confusing...but clarify on what you mean by
quoting context....I don't post here often so this will be good to
know Ravi

Read my .sig below.



Brian
 
R

ravi.sathyam

Hi,
Well the problem is solved...but a lesson was learned too..

Thanks,
Rob said:
Sorry - OK I guess I don't get this - why did you declare coef as
static?
Ravi

Ravi, please re-read Michael's response carefully. I'll highlight the
relevant portions:

"If you answer, please quote enough context." Please provide enough
context so that any particular message can be read by itself. Some
readers may have never seen your original post, nor Michael's response.
Some readers may have read those posts, but can no longer remember them
by the time they read your post. Please provide context in each and
every reply. Some newsreaders make this difficult, but not impossible.
If you are using Google Groups, for example, you have to perform special
magic to make this happen. The steps are described dozens of times per
day in this newsgroup alone.

"Please provide a minimal example." No one can debug your problem from
the incomplete data given in your original post, Michael's admirable
effort notwithstanding. please provide the smallest program you can that
still demonstrates your problem. Rather than make us guess which of the
ten million possible mistakes you might have made, we can tell you
precisely which one you did.

"The following ... fits your description." Your exchange so far reads
like this:
You: "I declare a static array called coef[10]".
Michael: "static int coef[10];".
You: "why did you declare coef as static?"
This precisely highlights why Michael wants to study your program,
instead of you studying his. We can't guess what is wrong with your
program from you inexact explanation. Only by pasting the exact program
that fails can we understand your problem.

I hope this helps. I look forward to seeing your response, with context,
and with a small program that demonstrates the error.

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,473
Latest member
pioneertraining

Latest Threads

Top