By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,475 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,475 IT Pros & Developers. It's quick & easy.

Compiler Error - help

P: n/a
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[i] = (int)(segment.coeff_Array[i]); -----------> 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

Nov 16 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
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

Nov 16 '05 #2

P: n/a
ra**********@gmail.com wrote:
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[i] = (int)(segment.coeff_Array[i]); -----------> 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[i] = segment.coeff_Array[i];
}

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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 16 '05 #3

P: n/a
Sorry - OK I guess I don't get this - why did you declare coef as
static?
Ravi

Nov 16 '05 #4

P: n/a
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.

ra**********@gmail.com wrote:
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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 16 '05 #5

P: n/a
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

Nov 16 '05 #6

P: n/a
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

Nov 16 '05 #7

P: n/a
ra**********@gmail.com wrote:
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

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
Nov 16 '05 #8

P: n/a
Michael Mair <Mi**********@invalid.invalid> writes:
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.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 16 '05 #9

P: n/a
ra**********@gmail.com wrote:
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
Nov 16 '05 #10

P: n/a
ra**********@gmail.com wrote:
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

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Nov 17 '05 #11

P: n/a
Hi,
Well the problem is solved...but a lesson was learned too..

Thanks,
Rob Adams wrote:
ra**********@gmail.com wrote:
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


Nov 18 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.