473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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.

Feb 11 '06 #1
3 2439
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)
Feb 11 '06 #2
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)


Feb 11 '06 #3
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.
Feb 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Todd Nathan | last post by:
Hi. have this code and compiler problem. GCC 2.95.3, BeOS, error "initializer element is not constant" #ifdef FILEIO { static struct { char *sfn; FILE *sfd; } stdfiles = {
13
by: devdatta_clc | last post by:
Hi C experts I've a bunch of questions. Consider this simplified piece of code. const int a = 10; int main () { static int b = a;
1
by: emin.martinian | last post by:
When trying to compile python extensions written in C using "python setup.py build" on cygwin I get the following error: foo.c: initializer element is not constant foo.c: error: (near...
5
by: fred | last post by:
Hi, Can someone explain me why gcc-4.0 gives me the 'Initializer element is not constant' error with this code ? Everything seems to be constant here... #include <stdio.h> typedef struct {...
7
by: Paul Edwards | last post by:
On ecgs (gcc) 2.91.57 and on gcc 3.2.3 I am getting the error "initializer element is not constant" on the below code. The code compiles fine with other compilers I have. Is this valid C89 code?...
1
varuns
by: varuns | last post by:
hi i m stuck while compiling my code for generating bindings for c code to be accessible from python i have read the ext.pdf available at python.org, and i think i have done every thing right. ...
1
varuns
by: varuns | last post by:
hi i m stuck while compiling my code for generating bindings for c code to be accessible from python i have read the ext.pdf available at python.org, and i think i have done every thing right. ...
2
by: hankypan1 | last post by:
Hi All, I need a tree data structure for my application. It is the non - cyclic simple tree where i can have any number of children node and each child can recursively become a sub tree like a...
16
by: Gowtham | last post by:
Hi, I had some C code written which initialized a global variable as: FILE *yyerfp = stdout; This used to work fine in older versions of gcc. Now, when I tried to compile this code (with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.