Csound Csound-dev Csound-tekno Search About

[Cs-dev] Could not compile current CVS

Date2007-04-28 20:06
FromAnthony Kozar
Subject[Cs-dev] Could not compile current CVS
Hello, 

I am wondering why no one else has noticed this yet.  Do newer C compilers
allow variable declarations to come after non-declaration code??

In csound.c, line 1140:

  int kperfThread(void * cs) {
    INSDS *start, *end;
    CSOUND *csound = (CSOUND *)cs;
    OPDS   *opstart;

    void *threadId = csound->GetCurrentThreadID();

    int index = getThreadIndex(csound, threadId);

    int numThreads = csound->oparms->numThreads;

    if(index < 0) {
       return -1;
    }

    void *barrier1 = csound->multiThreadedBarrier1;
    void *barrier2 = csound->multiThreadedBarrier2;


I need to move the void *barrierN declarations before the if statement in
order for this to compile.  (There are a few more instances of this error
later in the file as well).

There were several similar problems in vectorial.c with four instances of a
"long r" declaration.

I also had this error:

Error: illegal implicit conversion from 'int (*)(void *)' to
'unsigned long (*)(void *)'
main.c line 378   t->threadId = csound->CreateThread(&kperfThread, (void
*)csound);
Project: Csound5.cw8.mcp, Target: Csound5Lib Debug, Source File: main.c

So, it seems that kperfThread needs to return an unsigned long and therefore
that the line "return -1" needs to be changed.

I have made all of these changes and committed to CVS EXCEPT for the "return
-1" line in kperfThread.  I am not sure what the correction to that should
be (if anything) -- it compiles fine for me with the -1 being implicitly
converted to unsigned long.

Anthony


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-04-29 07:55
Fromjpff
SubjectRe: [Cs-dev] Could not compile current CVS
Unfortunately C99 does allow this very bad practice, as does C++.
I have modified some code of this type when I have seen it.
==John ffitch

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-04-29 08:43
From"Steven Yi"
SubjectRe: [Cs-dev] Could not compile current CVS
AttachmentsNone  

Date2007-04-29 10:58
Fromjpff
SubjectRe: [Cs-dev] Could not compile current CVS
Declaring as one goes leads to sloppy code -- not thinking and so on.
I spend so much of my time trying to educate the young in coding that
I dislike the undermining of good practice by language designers.  And
yes I have designed languages.
==John ffitch

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-04-29 15:00
FromAnthony Kozar
SubjectRe: [Cs-dev] Could not compile current CVS
The only problem for me is that since I "cut my teeth" on C++, I have a hard
time recognizing what is wrong when the compiler complains about this type
of error -- because it looks fine to me :)

But I have not done any serious coding in any language other than C since I
finished school several years ago ...

I'll mention again though that I did not change the line of code in
kperfThread() that returns -1; although the return type is now unsigned
long.  I am not sure whether that is a possible bug in the future or not.

Anthony


Steven Yi wrote on 4/29/07 3:43 AM:

> I don't think it's *so* bad a practice... =P  This is code I wrote and
> since I do a great deal of Java and not as much C/C++ I usually forget
> to be C89 compliant.  Looks like Anthony has checked in a fix so
> thanks Anthony!


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net