473,670 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_par ams_set_rate_ne ar' 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 2450
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_par ams_set_rate_ne ar' 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
19557
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
2563
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
2985
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 initialization for `FooType.ob_type') I remember someone telling me a long time ago that this had something to do with declspec and how dlls are imported on cygwin/python. Can someone give me a pointer to how to build python extensions on cygwin?
5
7874
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 { int a; int b;} t; int main(int argc, char** argv) {
7
10189
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? extern int *b; int *a = b; int main(void)
1
1803
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. But while compilation an error message is displayed demobox.c:495: error: initializer element is not constant demobox.c:495: error: (near initialization for `_PyDemoBox_methods.ml_meth') ......
1
4108
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. But while compilation an error message is displayed demobox.c:495: error: initializer element is not constant demobox.c:495: error: (near initialization for `_PyDemoBox_methods.ml_meth')
2
4994
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 normal tree. Now the thing is i can popullate my tree at compile time like a global data. Since i know my tree definition at compile time, instead of using pointers to point to siblings or child nodes, i am planning to use the array
16
2768
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 gcc 3.2.3), I got errors like:
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7419
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5684
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2800
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.