Hi, I am building savonet from cvs using gcc, and in some packages (ocaml-shout, ocaml-vorbis, ...) variables are declared in the middle of a block of code, rather than at the top. This is allowed in C++, but not ANSI C -- so gcc returns a parse error on undeclared variables. (Are you all using a non-gcc c compiler? or c++?)
Fixing this is pretty easy -- patches are attached so that they compile with gcc. -- matt toups [EMAIL PROTECTED] http://www.andrew.cmu.edu/~mtoups/mykey.gpg
--- ocaml-vorbis/src/vorbis_stubs.c 24 Feb 2004 14:27:51 -0000 1.17
+++ ocaml-vorbis/src/vorbis_stubs.c 15 Mar 2004 04:48:14 -0000
@@ -116,6 +116,7 @@
//TODO: check parameters consistency
CAMLprim value ocaml_vorbis_create_encoder(value params)
{
+ CAMLlocal1(block);
CAMLparam1(params);
myvorbis_encoder_t *ve;
@@ -204,7 +205,6 @@
ogg_stream_init(&ve->os, serialno);
- CAMLlocal1(block);
block = alloc_final(2, finalize_myvorbis_encoder_t,
sizeof(myvorbis_encoder_t), 1024);
Field(block, 1) = (value)ve;
CAMLreturn(block);
@@ -258,6 +258,7 @@
char *ret = NULL;
int ret_len = 0;
+ value s;
/* Now, build the three header packets and send through to the stream
output stage (but defer actual file output until the main encode loop) */
@@ -303,7 +304,7 @@
}
}
- value s = copy_buffer(ret, ret_len);
+ s = copy_buffer(ret, ret_len);
free(ret);
CAMLreturn(s);
}
@@ -325,10 +326,11 @@
int bytes_read;
int i, j;
int realsamples;
+ float **buffer;
realsamples = len / (sampbyte * ve->in_channels);
*buffer_ = vorbis_analysis_buffer(&ve->vd, realsamples);
- float **buffer = *buffer_;
+ buffer = *buffer_;
bytes_read = realsamples * sampbyte * ve->in_channels;
buf = (char*)malloc(bytes_read);
memcpy(buf, in, bytes_read);
@@ -385,6 +387,7 @@
char *ret = NULL;
int ret_len = 0;
int eos = 0;
+ value s;
if(samples_read == 0)
/* Tell the library that we wrote 0 bytes - signalling the end */
@@ -425,7 +428,7 @@
}
}
- value s = copy_buffer(ret, ret_len);
+ s = copy_buffer(ret, ret_len);
free(ret);
CAMLreturn(s);
@@ -463,6 +466,7 @@
CAMLprim value ocaml_vorbis_open_dec_file(value fd, value params)
{
CAMLparam2(fd, params);
+ CAMLlocal1(block);
FILE *in = NULL;
myvorbis_dec_file_t *df =
(myvorbis_dec_file_t*)malloc(sizeof(myvorbis_dec_file_t));
@@ -482,7 +486,6 @@
raise_constant(*caml_named_value("vorbis_exn_not_a_vorbis_file"));
}
- CAMLlocal1(block);
block = alloc_final(2, finalize_myvorbis_dec_file_t,
sizeof(myvorbis_dec_file_t), 1000);
Field(block, 1) = (value)df;
CAMLreturn(block);
--- ocaml-shout/src/shout_stubs.c 18 Dec 2003 15:15:32 -0000 1.4
+++ ocaml-shout/src/shout_stubs.c 15 Mar 2004 04:30:21 -0000
@@ -459,16 +459,18 @@
CAMLparam2(block, data);
shout_t *s = shout_of_block(block);
shout_metadata_t *metadata = shout_metadata_new();
- int i;
+ int i,ret;
+ char *name, *val;
+
for (i=0; i<Wosize_val(data); i++)
{
CAMLlocal1(c);
c = Field(data, i);
- char *name = String_val(Field(c, 0));
- char *val = String_val(Field(c, 1));
+ name = String_val(Field(c, 0));
+ val = String_val(Field(c, 1));
shout_metadata_add(metadata, name, val);
}
- int ret = shout_set_metadata(s, metadata);
+ ret = shout_set_metadata(s, metadata);
shout_metadata_free(metadata);
CAMLreturn(unit_or_error(ret));
}
From [EMAIL PROTECTED] Mon Mar 15 00:45:51 2004
Date: Mon, 15 Mar 2004 00:45:32 -0500
From: m. toups <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
? ocaml-mad/src/._bcdi
? ocaml-mad/src/._d
? ocaml-mad/src/._ncdi
? ocaml-mad/src/META
? ocaml-mad/src/Makefile
? ocaml-mad/src/mad.cma
? ocaml-mad/src/mad.cmi
? ocaml-mad/src/mad.cmo
? ocaml-mad/src/mad.cmx
? ocaml-mad/src/mad.cmxa
Index: ocaml-mad/src/mad_stubs.c
===================================================================
RCS file: /cvsroot/savonet/savonet/ocaml-mad/src/mad_stubs.c,v
retrieving revision 1.22
diff -u -r1.22 mad_stubs.c
--- ocaml-mad/src/mad_stubs.c 29 Feb 2004 11:47:33 -0000 1.22
+++ ocaml-mad/src/mad_stubs.c 15 Mar 2004 05:17:42 -0000
@@ -115,6 +115,7 @@
CAMLprim value ocaml_openfile(value fd)
{
CAMLparam1(fd);
+ CAMLlocal1(block);
madfile_t *mf;
mf = (madfile_t*)malloc(sizeof(madfile_t));
mad_stream_init(&mf->stream);
@@ -126,7 +127,6 @@
raise_with_arg(*caml_named_value("mad_exn_openfile_error"),
copy_string((char*)strerror(errno)));
mf->buf = (char*)malloc(BUFFER_SIZE);
- CAMLlocal1(block);
block = alloc_final(2, finalize_madfile_t, sizeof(madfile_t), BUFFER_SIZE +
1024);
Field(block, 1) = (value)mf;
CAMLreturn(block);
@@ -155,6 +155,7 @@
CAMLprim value ocaml_decode_frame(value madf)
{
CAMLparam1(madf);
+ CAMLlocal1(ret);
madfile_t *mf = madfile_of_block(madf);
char *output_buf = NULL;
int output_pos = 0;
@@ -305,7 +306,6 @@
* are temporarily stored in a buffer that is flushed when
* full.
*/
- CAMLlocal1(ret);
ret = alloc_string(mf->synth.pcm.length * 4);
output_buf = String_val(ret);
pgpAvSGHTpeGc.pgp
Description: PGP signature
