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

L

Levi Campbell

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

Richard Heathfield

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];
 
L

Levi Campbell

Holy crap, it worked and it didn't segfault! Thank you.

Richard said:
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)
 
F

Flash Gordon

Levi Campbell wrote:

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.

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>
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top