C99 mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

C99 mode

Post by BMW »

When I tried to use a for(int i=0;i<2000;i++) in my kernel, it says for-loop initial declaration is only allowed in C99 mode.

Should I use C99 mode for kernel development?
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: C99 mode

Post by iansjack »

I just stick with the default and don't declare variables in the loop initialiser. No big deal.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: C99 mode

Post by bluemoon »

I'm using c99 switch, not because of for-loop initialization but just stick to a "recent" and stable standard (compare to c90).
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: C99 mode

Post by Love4Boobies »

Why would you recmmend using a version of the C language that is 24 years old, as if C wasn't a bad language already? If you really must use it, you should be rely on its most recent version (i.e., C11, although note that most compilers don't fully implement it yet). Languages, just like software, evolve for two reasons: (a) bugs, and (b) their requirements change (which is an obvious thing to happen as new technology, methodologies, and techniques develop or old ones improve). The only reason to use C89 is to compile old, C89 code.

As to why C89 is the default mode of GCC, which is probably the compiler you are using, it's so that it won't break compatibility with old build systems which expect C89 because that's the only thing that existed back when the projects they are part of were written... After all, you can't break forwards compatibility.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: C99 mode

Post by BMW »

bluemoon wrote:I'm using c99 switch, not because of for-loop initialization but just stick to a "recent" and stable standard (compare to c90).
Ok thats what I'll do.

Thanks.
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Post Reply