Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > playfunc.c:524: error: initializer element is not constant

Reply
Thread Tools

playfunc.c:524: error: initializer element is not constant

 
 
Levi Campbell
Guest
Posts: n/a
 
      02-11-2006
Hi, I'm trying to debug an app someone else wrote called eMixer. Here's
the log contents:

cc -O3 -funroll-loops -c -o main.o main.c

cc -O3 -funroll-loops -c -o nctgui.o nctgui.c

cc -O3 -funroll-loops -c -o mixer.o mixer.c

mixer.c: In function `open_soundcard_alsa':

mixer.c:201: warning: passing arg 3 of
`snd_pcm_hw_params_set_rate_near' makes pointer from integer without a
cast

cc -O3 -funroll-loops -c -o getlopt.o getlopt.c

cc -O3 -funroll-loops -c -o plstfunc.o plstfunc.c

cc -O3 -funroll-loops -c -o playfunc.o playfunc.c

playfunc.c: In function `do_autofade':

playfunc.c:524: error: initializer element is not constant

playfunc.c:524: error: (near initialization for `checkmode[0][0]')

playfunc.c:524: error: initializer element is not constant

playfunc.c:524: error: (near initialization for `checkmode[0][1]')

playfunc.c:524: error: initializer element is not constant

playfunc.c:524: error: (near initialization for `checkmode[0]')


And the line in question looks like this:

static int checkmode[3][2]={(0,0,0),(0,0,0)};

To try and solve this problem, I've commented out the static part and
while the program compiles, it segfaults when you try and run it. I've
also tried adding -ansi to the CFLAGS but that doesn't work. When I
searched the web, I got lots of hits about other people having the same
problem, but the code wasen't close enough that I could get an idea of
how thhe problem was fixed. does anyone have any ideas about what I
need to do here? Thank you for your time.

 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      02-11-2006
Levi Campbell said:

> And the line in question looks like this:
>
> static int checkmode[3][2]={(0,0,0),(0,0,0)};


That should be:

static int checkmode[3][2] = {{0, 0}, {0, 0}, {0, 0}};

or simply:

static int checkmode[3][2] = {0};

or even (because it's static):

static int checkmode[3][2];

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
 
 
 
Levi Campbell
Guest
Posts: n/a
 
      02-11-2006
Holy crap, it worked and it didn't segfault! Thank you.

Richard Heathfield wrote:
> Levi Campbell said:
>
> > And the line in question looks like this:
> >
> > static int checkmode[3][2]={(0,0,0),(0,0,0)};

>
> That should be:
>
> static int checkmode[3][2] = {{0, 0}, {0, 0}, {0, 0}};
>
> or simply:
>
> static int checkmode[3][2] = {0};
>
> or even (because it's static):
>
> static int checkmode[3][2];
>
> --
> Richard Heathfield
> "Usenet is a strange place" - dmr 29/7/1999
> http://www.cpax.org.uk
> email: rjh at above domain (but drop the www, obviously)


 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      02-11-2006
Levi Campbell wrote:

<snip>

> cc -O3 -funroll-loops -c -o mixer.o mixer.c
>
> mixer.c: In function `open_soundcard_alsa':
>
> mixer.c:201: warning: passing arg 3 of
> `snd_pcm_hw_params_set_rate_near' makes pointer from integer without a
> cast


Something Richard did not mention is that this is a potentially very
serious warning and you really should track it down and fix the issue.
However, do *not* fix it by simply adding a cast, that would almost
certainly be the *wrong* thing to do.

<snip>

> also tried adding -ansi to the CFLAGS but that doesn't work. When I


<OT>
That is a good switch to use. You might also want to add the following
-pedantic -Wall -O
These switches have the potential to catch a lot more problems in the code.
</OT>
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Initializer element is not constant fred@mayot.net C Programming 5 08-08-2006 02:08 PM
"initializer element is not constant" emin.martinian@gmail.com Python 1 05-30-2006 10:15 PM
Initializer element not constant grid C Programming 8 08-02-2005 11:56 AM
initializer element is not constant Scott C Programming 15 01-24-2005 04:33 AM
Error: "initializer element is not constant" Todd Nathan C Programming 2 07-30-2003 04:29 PM



Advertisments