[Csnd-dev] Misleading indentation
Date | 2018-02-01 14:57 |
From | Michael Gogins |
Subject | [Csnd-dev] Misleading indentation |
I recently upgraded to gcc 7 and am now getting many compiler errors in Csound such as this: /home/mkg/csound-extended/dependencies/csound/Engine/insert.c:172:4: error: this ‘else’ clause does not guard... [-Werror=misleading-indentation] The cause of these errors is generally coding something like if(!csound->oparms->realtime) // no API lock in realtime mode csoundUnlockMutex(csound->API_lock); while the C compiler will now only pass if(!csound->oparms->realtime) {// no API lock in realtime mode csoundUnlockMutex(csound->API_lock); } This usage used to be acceptable to the compiler, though it has for a long time been forbidden by most C and C++ coding standards. The usage is now explicitly a compiler error. Should we turn this error off, or fix the code to be more up to date? Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com |
Date | 2018-02-01 15:26 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Misleading indentation |
You could add -Wno-misleading identation to your custom.cmake while I fix this in the sources. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 1 Feb 2018, at 14:57, Michael Gogins |
Date | 2018-02-01 15:37 |
From | jpff |
Subject | Re: [Csnd-dev] Misleading indentation |
I see nothing wrong wit the source. Apart from a missing space that is. On Thu, 1 Feb 2018, Victor Lazzarini wrote: > You could add -Wno-misleading identation to your custom.cmake while I fix > this in the sources. > ======================== > Prof. Victor Lazzarini > Dean of Arts, Celtic Studies, and Philosophy, > Maynooth University, > Maynooth, Co Kildare, Ireland > Tel: 00 353 7086936 > Fax: 00 353 1 7086952 > >> On 1 Feb 2018, at 14:57, Michael Gogins |
Date | 2018-02-01 16:08 |
From | Michael Gogins |
Subject | Re: [Csnd-dev] Misleading indentation |
There is something wrong with the source. The current compiler does not pass sources that were OK with the older compiler. The standard for C and the standard for C++ have become more stringent. I think we should definitely try to keep up with the compiler. Best, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Feb 1, 2018 at 10:37 AM, jpff |
Date | 2018-02-01 16:12 |
From | Dave Seidel |
Subject | Re: [Csnd-dev] Misleading indentation |
Yea, they're enforcing the use of curly braces to enclose a single-line block. I think this is good practice, and I follow it myself (albeit in Java), but it seems a bit drastic to fail a compile on that basis. On Thu, Feb 1, 2018 at 11:08 AM, Michael Gogins <michael.gogins@gmail.com> wrote: There is something wrong with the source. The current compiler does |
Date | 2018-02-01 16:16 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Misleading indentation |
That’s what I proposed, to fix this issue in the sources. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy Maynooth University Ireland > On 1 Feb 2018, at 16:09, Michael Gogins |
Date | 2018-02-01 16:18 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Misleading indentation |
It fails because we have -Werror as we want to enforce zero warnings. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland
|
Date | 2018-02-01 18:35 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Misleading indentation |
I fixed all of these (or at least the ones I saw in my gcc 6 build for arm). I will try to upgrade my ubuntu gcc because that build is more complete and might find other cases. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 1 Feb 2018, at 14:57, Michael Gogins |
Date | 2018-02-01 20:08 |
From | Michael Gogins |
Subject | Re: [Csnd-dev] Misleading indentation |
Thanks for this necessary work. Let me know if you want help, and if so how. Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Feb 1, 2018 at 1:35 PM, Victor Lazzarini |
Date | 2018-02-01 20:33 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Misleading indentation |
I setup a Debian build with gcc 6 and all dependencies. It seems to pass everything now. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 1 Feb 2018, at 20:08, Michael Gogins |
Date | 2018-02-01 21:01 |
From | Michael Gogins |
Subject | Re: [Csnd-dev] Misleading indentation |
I am running gcc 7 as I have moved to Ubuntu 17.10. I will go ahead, then, and make such additional corrections as are required to compile with -Werror. Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Feb 1, 2018 at 3:33 PM, Victor Lazzarini |
Date | 2018-02-02 04:43 |
From | Michael Gogins |
Subject | Re: [Csnd-dev] Misleading indentation |
I have pushed changes to build all of Csound using GCC 7.2.0 with -Werror. There are pragmas in some files and additional target compiler flags for some files. Not really that many changes. Changes were necessary in some of my C++ opcode files and in some core Csound files. SWIG generated files have to be compiled with -Wno-error. I tried to ensure that these changes are safe for OS X and MSVC, but I can't test that here. Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Thu, Feb 1, 2018 at 4:01 PM, Michael Gogins |
Date | 2018-02-02 20:30 |
From | jpff |
Subject | Re: [Csnd-dev] Misleading indentation |
There are many examples in csound that the form "if () statement" after today's changes.nWhat exactly is supposed to be bad? On Thu, 1 Feb 2018, Michael Gogins wrote: > I recently upgraded to gcc 7 and am now getting many compiler errors > in Csound such as this: > > /home/mkg/csound-extended/dependencies/csound/Engine/insert.c:172:4: > error: this ‘else’ clause does not guard... > [-Werror=misleading-indentation] > > The cause of these errors is generally coding something like > > if(!csound->oparms->realtime) // no API lock in realtime mode > csoundUnlockMutex(csound->API_lock); > > while the C compiler will now only pass > > if(!csound->oparms->realtime) {// no API lock in realtime mode > csoundUnlockMutex(csound->API_lock); > } > > > This usage used to be acceptable to the compiler, though it has for a > long time been forbidden by most C and C++ coding standards. The usage > is now explicitly a compiler error. > > Should we turn this error off, or fix the code to be more up to date? > > Regards, > Mike > ----------------------------------------------------- > Michael Gogins > Irreducible Productions > http://michaelgogins.tumblr.com > Michael dot Gogins at gmail dot com > |
Date | 2018-02-02 20:36 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Misleading indentation |
I think when the text formatting looks unclear to the compiler, it complains and asks for it to be clarified/checked up. That’s my understanding from the instances I fixed. A typical example was if( ) statement; statement; this would trigger the warning. Changing the formatting or adding brackets would fix it. I guess it all helps us to make sure we mean what we write. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy Maynooth University Ireland > On 2 Feb 2018, at 20:30, jpff |
Date | 2018-02-02 20:55 |
From | Michael Gogins |
Subject | Re: [Csnd-dev] Misleading indentation |
It is bad because it does not compile with the -Werror option in GCC 7 (and maybe 6). And it is bad for GCC because it can be misleading to read if indentation is messed up. As it sometimes is in our code. Best, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Fri, Feb 2, 2018 at 3:36 PM, Victor Lazzarini |