View Full Version : C99?
file13
04-21-2003, 03:29 PM
hey all, i've been learning a wee bit of objective-c to do some OS X hacking and one of the examples made a comment about if you got an error you might not have gcc 3.1 which suports C99 features. the thing that was different from regular C stuff was simply that they didn't have to declare all variables before any code in a function. i take it this is a feature of C99?
basically my questions are, can anyone confirm how much of the C99 standard gcc 3.1 implements and what are some of the high points when it comes to new features of C99? i've read some stuff about it, but since it was always, (there's no compiler that supports it) it never got into any depth. also, if it is indeed a reality, how many C hackers are planning to migrate?
sicarius
04-21-2003, 09:24 PM
I would venture to guess that c99 would be safe to use once it is "standardized" by ISO or ANSI. Although even if a compiler implements the ISO or ANSI standard it may take upon itself the responsibility for adding extras to the language.
For instance the ANSI C and C++ standards don't support the nesting of multi-line comments, but it is so convenient for a programmer to "block out" massive chunks of code, that a lot of compilers allow it. I understand this is a small example, but the point is who gets hurt with something like that?
Even the case with where you have to declare variables doesn't really change the outcome of compilation very much. I would imagine that you will see some compilers take the cooler features of c99 and implement them, but of course the only safe way to right code in C is to make it ISO or ANSI compliant.
file13
04-22-2003, 10:47 AM
thanks sicarius for the input. just trying to get these forums back to life.... ;)
just an FYI, C99 is ANSI/ISO:
source:
http://www.e-businessworld.com/english/crd_language_303983.html
so basically we're at the stage where we were/are with C++. having a standard but no compilers to implement it. as for GCC i found this about what it implements:
http://gcc.gnu.org/c99status.html
and it does mention that "mixed declarations and code" and "// comments" are implemented.
one major thing i'm kinda curious about are the "variable length arrays"--which are broken in gcc. i honestly don't undestand the implications of these. are these dynamic arrays? does anyone know if this addition will help with C's nasty string problems? any insight would be appreciated.
also, anyone know why they didn't add some kind of module/name hiding system? name clashes in large code seem to be a big problem in C and i'm kinda suprised the new standard dosen't address this. thoughts?
sicarius
04-22-2003, 05:58 PM
Yeah a module hiding feature would be nice. That is one great (out of many) things with ObjectiveC, its #import statment makes sure that only one copy of a header file is included, so you don't have to protect your headers with #ifdef.
The thing i mentioned before with the commenting was for the multi-line comment (/* */). I don't have time to read the articles you posted until I get home from work, but they sound interesting.
file13
04-22-2003, 06:50 PM
nifty, yeah i'm just checking out obj-c since i got a Mac but i haven't gotten to import yet. so far it's an interesting superset of C. but yeah, i got a ways to go before i can really comment on it--need more time.... :suspect:
stuka
04-24-2003, 11:35 AM
sicarius: /* */ comments are native to older C - the // comments are newer (C++, C99).
file13: Variable length arrays are indeed dynamic arrays. The C/C++ User's Journal did a series of articles on C99 - I don't know if all are viewable from the website (http://www.cuj.com ) but there may be some sample code there.
file13
04-24-2003, 01:45 PM
very cool! unfortunately i didn't find anything on the website. so do these arrays grow and shrink automatically (like a C++ vector) so you don't have to malloc them? don't suppose you have any examples yourself?
thanks Stuka!
stuka
04-24-2003, 02:50 PM
Not a problem - I'll see if I can't find something in an old CUJ, since I haven't used C99 myself.
sicarius
04-25-2003, 12:05 AM
I wasn't saying that /* */ or // didn't exist in C or C++, I was saying that you can't nest /* */ in the C or C++ languages (according to the language specs).
so:
/*
/* */
*/
isn't cool.
but
// // // //
is perfectly fine.
as far as native goes....I don't recall not being able to use // in my C programs prior to 1999.
stuka
04-25-2003, 10:55 AM
Ah...I gotcha 'bout the nested stuff. And the // wasn't part of the ISO/ANSI standard C until '99 - not that compilers didn't allow it, just that it wasn't part of the standard.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.