Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

Fri Sep 29, 2017 4:22 pm

jahboater wrote:
Fri Sep 29, 2017 4:16 pm
Martin Frezman wrote:
Fri Sep 29, 2017 4:15 pm
and in the documentation:
*WHICH* documentation? Which OS/version-of-gcc did you get that from?
Sorry, "man gcc"

Raspbian stretch / the default compiler (gcc 6.3)
Right. No one doubts that in Stench they (finally!) upgraded to a more-or-less current version of GCC. The discussion has been about whether or not it worked in the default version of GCC found in Jessie. To which the answer is "No".

And, given poster's latest post, it seems clear that he was using C++ all along...
If this post appears in the wrong forums category, my apologies.

Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

Fri Sep 29, 2017 4:23 pm

Stiller wrote:
Fri Sep 29, 2017 4:22 pm
well, ok, I'm a beginner to C, I didn't know there is a difference between gcc and g++ compiler calls :mrgreen:
Yes. There is also a difference between C and Fortran.
If this post appears in the wrong forums category, my apologies.

Stiller
Posts: 206
Joined: Fri Oct 14, 2016 9:03 am

Re: Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

Fri Sep 29, 2017 4:26 pm

yes, but C is a subset of C++, and Fortran isn't :ugeek:

User avatar
Paeryn
Posts: 2698
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

Fri Sep 29, 2017 8:12 pm

Stiller wrote:
Fri Sep 29, 2017 4:26 pm
yes, but C is a subset of C++, and Fortran isn't :ugeek:
No, C is not a subset of C++, they share a large part but you can write perfectly valid C that won't compile in C++ without changes or which behaves differently.
She who travels light — forgot something.

jahboater
Posts: 4760
Joined: Wed Feb 04, 2015 6:38 pm

Re: Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode

Sat Sep 30, 2017 9:08 am

Yes, there is the "restrict" keyword which isn't supported in C++, the annoying casts needed when converting from a void* ......

I believe part of the rationale behind C99 and C11 was to bring C back to being a subset of C++ as it was in the old days (C++ was originally called "C with Classes"). C99 especially, had lots of good stuff from C++ included.

From Mr Stroustrup (The C++ Programming Language Fourth Edition - end of page 1271):
"Well-written C programs tend to be C++ programs as well."

Return to “C/C++”