Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

C99

Name: Anonymous 2007-05-08 14:15 ID:q5/F6Oa1

Where can I find a good introduction to the features introduced in C99? I just realized that my C is still stuck with K&R ed. 2.

Name: Anonymous 2007-05-08 14:37 ID:pXwRFSNB

...dont use C99

Name: Anonymous 2007-05-08 14:38 ID:8c9mlFDF

>>2
don't listen to this man

Name: Anonymous 2007-05-08 14:52 ID:orddlkZI

LOL C. Enjoy scratching your beard trying to figure out how to do the most trivial tasks.

Name: Anonymous 2007-05-08 14:55 ID:8c9mlFDF

>>4
lol. enjoy your tremendously slow speeds. VROOM VROOM.

Name: Anonymous 2007-05-08 14:57 ID:orddlkZI

>>4
Enjoy your 1950s programming mentality, Grandpa.

Name: Anonymous 2007-05-08 14:57 ID:q5/F6Oa1

>>4
LOL shutup. I've used C for over ten years and know exactly how tedious it is. I mostly use Haskell and Python these days, but sometimes C is very necessary.

Name: Anonymous 2007-05-08 14:58 ID:8c9mlFDF

    /* C89 */
    {
        struct timeval tv = { 0, n };
        select(0, 0, 0, 0, &tv);
    }

    // C99
    select(0, 0, 0, 0, & (struct timeval) { .tv_usec = n });

Listing 3. A structure with a flexible array

    struct header {
        size_t len;
        unsigned char data[];
    };

>This structure has the useful property that if you allocate space for (sizeof(struct header) + 10) bytes, you can treat data as being an array of 10 bytes. This new syntax is supported in gcc.

Name: Anonymous 2007-05-08 15:02 ID:8c9mlFDF

   1. Increased identifier size limits: specifically 63 significant initial characters in an internal identifier or macro name, 31 significant initial characters in an external identifier, and 4095 characters in a logical source line. These values were 31, 6, and 509, respectively, in C89.

      The small identifier size is the reason so many ANSI functions had terse names (strcpy, strstr, strchr, etc) since the standard only guaranteed that the first six characters would be used to uniquely identify the functions.

   2. C++ style/line comments: The characters '//' can now be used to delineate a line of commented text, just like in C++.

   3. Macros take variable arguments denoted by elipsees: Function-like macros will accept variable arguments denoted by using the ellipsis (...) notation. For replacement, the variable arguments (including the separating commas) are "collected" into one single extra argument that can be referenced as __VA_ARGS__ within the macro's replacement list.

   4. Inline functions: The C language now supports the inline keyword which allows functions to be defined as inline, which is a hint to the compiler that invocations of such functions can be replaced with inline code expansions rather than actual function calls.

   5. Restricted pointers: The C language now supports the restrict keyword which allows pointers to be defined as restricted, which is a hint to the compiler to disallow two restricted pointers from being aliases to the same object which allows for certain optimizations when dealing with the said pointers.

   6. _Bool Macro: There is a _Bool type which is a actually two valued integer type. True is defined as

          #define true (_Bool)1

      while false is defined as

          #define false (_Bool)0

   7. Variable Declarations can appear anywhere in the code block: No longer do variables have to be defined at the top of the code block.

   8. Variable length arrays: These are arrays whose size is determined at runtime.

   9. Variable declarations in for loops: Variables can now be declared and initialized in for loops just like in C++ and Java.

  10. Named initialization of structs: The members of a struct can now be initialized by name such as is done in the code block below

          struct {float x, y, z;} s = { .y = 1.0, .x = 3.5, .z = 12.8};

  11. New long long type: There is a new type called long long which is at least 64 bits and can be both signed or unsigned. The new suffixes "LL" or "ll" (and "ULL" or "ull") are used for constants of the new long long type.

  12. Functions must declare a return value: Function return types no longer defaults to int if the function declares no return type.

  13. Last member of a struct may be an incomplete array type. : This is to support the "struct hack" which works on most existing C compilers already. A code example of the struct hack is shown on Thomas's site.

  14. Addition of _Complex and _Imaginary number types: A boon for programmers doing any sort of advanced math in their programs.

  15. Multiple uses of a type qualifier are ignored after the first occurence: If a type qualifier appears several times (either directly or indirectly through typedefs) in a type specification, it's treated as if it appeared only once. E.g.

          const const int x;

      is the same as

          const int x;

Name: Anonymous 2007-05-08 16:33 ID:UZbxCNCb

Heh. Identifiers, comments, inline functions, variable declarations anywhere, long long and struct hack were working with many non-C99 compilers. Others such as functions must return a value or you can repeat type qualifiers are pretty much useless. So the C commitee is so busy adding complex numbers to C while there are no lists, the language still lacks strings, Unicode is unheard of (there's some half-assed underspecification for obscure "multibyte strings" and "wide characters"), and the standard library is a piece of shit full of braindamaged functions such as gets; also completely useless for even the most basic tasks (C without POSIX and usual compiler extensions is a joke). Way to go.

C2009 will probably include additional features for use in the IOCCC, as well as a library to find Carmichael numbers, and keep the shitty standard library and no Unicode.

Name: Anonymous 2007-05-08 16:40 ID:Pzrdv15X

>>7
NO U I AM EXPERT PROGRAMMER DONT HAVE TO EXPLAIN MYSELF!!!!! I ALWAYS RIGHT!!!!!

Name: Anonymous 2007-05-08 17:02 ID:uEhc0Lsx

ANSI C or GTFO

the choice is yours, sir

Name: Anonymous 2007-05-08 17:22 ID:u6sd4/M/

>>4
try doing this in your shitty language:
#include <stdio.h>

void enc_xtea(unsigned int rounds,unsigned long* v,unsigned long* k){
 unsigned long i,sum=0,delta=0x9e3779b9;
 for(i=0;i<rounds;++i){
  v[0]+=(((v[1]<<4)^(v[1]>>5))+v[1])^(sum+k[sum&3]);
  sum+=delta;
  v[1]+=(((v[0]<<4)^(v[0]>>5))+v[0])^(sum+k[(sum>>11)&3]);
 }
}

void dec_xtea(unsigned int rounds,unsigned long* v,unsigned long* k){
 unsigned long i,delta=0x9e3779b9,sum=delta*rounds;
 for(i=0;i<rounds;++i){
  v[1]-=(((v[0]<<4)^(v[0]>>5))+v[0])^(sum+k[(sum>>11)&3]);
  sum-=delta;
  v[0]-=(((v[1]<<4)^(v[1]>>5))+v[1])^(sum+k[sum&3]);
 }
}

void enc_str_xtea(unsigned int len,unsigned char* message,unsigned long* k,unsigned int rounds){
 unsigned int l=len/8,i;
 if(len%8)
  ++l;
 for(i=0;i<l;++i){
  if(i){
   ((unsigned long*)message)[i<<1]^=((unsigned long*)message)[(i-1)<<1];
   ((unsigned long*)message)[(i<<1)+1]^=((unsigned long*)message)[((i-1)<<1)+1];
  }
  enc_xtea(rounds,((unsigned long*)message)+(i<<1),k);
 }
}

void dec_str_xtea(unsigned int len,unsigned char* message,unsigned long* k,unsigned int rounds){
 unsigned int l=len/8,i;
 unsigned long t[4]={0};
 if(len%8)
  ++l;
 for(i=0;i<l;++i){
  t[0]=((unsigned long*)message)[i<<1];
  t[1]=((unsigned long*)message)[(i<<1)+1];
  dec_xtea(rounds,((unsigned long*)message)+(i<<1),k);
  if(i){
   ((unsigned long*)message)[i<<1]^=t[2];
   ((unsigned long*)message)[(i<<1)+1]^=t[3];
  }
  t[2]=t[0];
  t[3]=t[1];
 }
}

int main(){
 char message[]="lol whut";
 char key[]="super sekret key";
 puts(message);
 enc_str_xtea(8,message,(unsigned long*)key,1024);
 puts(message);
 dec_str_xtea(8,message,(unsigned long*)key,1024);
 puts(message);
 return 0;
}

Name: Anonymous 2007-05-08 17:54 ID:GzVIAdO+

C2009 will probably include additional features for use in the IOCCC, as well as a library to find Carmichael numbers, and keep the shitty standard library and no Unicode.
Fucking signed. I can mostly live with the language as it is now. What it really needs is a better standard library.

Those guys are useless. :(

Name: Anonymous 2007-05-08 17:59 ID:Heaven

no Unicode.
using utf-32 is ridiculously easy in c, and converting between utf-32 and utf-8 is trivial.

>>14
what does the standard library need that it doesn't already have?

Name: Anonymous 2007-05-08 18:07 ID:Heaven

>>15
A Lisp interpreter.

Name: Anonymous 2007-05-08 18:35 ID:UZbxCNCb

>>15
1. Strings (note: string.h, save for mem*, is shit).
2. Unicode. SEMANTICS MOTHERFUCKER, DO YOU USE THEM? Also, specifying Unicode support wouldn't hurt. Also, this "multibyte" mess is shit. Decent UTF-8, UTF-16 and UTF-32 support is a must.
3. Decently thought out functions (scanf? gets? strtok?) that have more functionality, less OH EXPLOITABLE owl.
4. time.h is shit, throw away and redo.
5. Half of stdio.h sucks.
6. Missing standard OS interface, even for the fucking filesystem! There's rename but there's no glob/findfirst? Most of unistd should have been specified as part of the standard library.
7. Missing basic libraries everybody writes for every fucking project: buffers and dynamic lists, sorted or not, doubly linked lists too.
8. Dictionaries (hashes) would also be of great help, and that's what a standard library is about.
9. Missing regular expressions. Something like PCRE, only with an usable API would be great.
10. NETWORK MOTHERFUCKER, BSD sockets need to be specified as part of the standard library too.
11. Portable threads, where are they. I'm also missing semaphores and IPC.
12. Higher-level utilities would be good too: template for a socket server, HTTP client, FTP client, SSL, AES, DES, MD5, SHA1, SHA-256, SMTP, POP, IMAP, RFC 822, MIME, Base64, quoted-printable, HTML quoting, URI handling, SAX, DOM, XPath query, INI files, getopt, platform-independent application configuration, platform introspection...
13. All you can do is stdin/stdout hacks. Missing ncurses-like library for generalized character-based Unicode terminals.
14. Missing platform-agnostic UI toolkit to allow simple, portable character-mode or graphics-mode interfaces.
15. Missing standard, platform agnostic low-level core multimedia services. Something like SDL.
16. Optional but standard garbage collector.

Think how would things be if they had equipped C with a decent standard library; one that allows you to write more than stdin/stdout lumps of horribly vulnerable crap in a standard fashion. Perhaps we wouldn't have Java, because the C standard library would have grown to do what it does in a standard, portable way. Most of POSIX should really have been C. Think how great would things be if we had a portable, usable, useful out-of-the-box C that doesn't require a gazillion of libraries before you can start doing anything useful with it.

Name: Anonymous 2007-05-08 18:42 ID:Heaven

>>17
why not just write your own libxbox and use that?

Name: Anonymous 2007-05-08 18:43 ID:j69pAHl6

>>17
You're an awful programmer, go read your shit better.
I'd answer to everything but i'm bored.

9. Missing regular expressions. Something like PCRE, only with an usable API would be great.
TRE.

10. NETWORK MOTHERFUCKER, BSD sockets need to be specified as part of the standard library too.
die

12. Higher-level utilities would be good too: template for a socket server, HTTP client, FTP client, SSL, AES, DES, MD5, SHA1, SHA-256, SMTP, POP, IMAP, RFC 822, MIME, Base64, quoted-printable, HTML quoting, URI handling, SAX, DOM, XPath query, INI files, getopt, platform-independent application configuration, platform introspection...
This is C. hardcode or gtfo

Think how would things be if they had equipped C with a decent standard library; one that allows you to write more than stdin/stdout lumps of horribly vulnerable crap in a standard fashion.
So wait, remind me what is wrong with 3rd party libraries ?


You're a fucking idiot, man i can't be fucked to answer seriously to such shitty posts.
Deep inside me, i hope you're a troll.

Name: Anonymous 2007-05-08 18:56 ID:UZbxCNCb

Sure, keep the standard library tiny and C will never be anything but a portable assembly language.

A big standard library means a lot of portable functionality out of the box, specified in a standard stricter than any third party library would use, and a standard tool to know and maintain (less fragmented community is a Good Thing), instead of 40 different third-party libraries. It means no collecting 20 libraries like a moron until you can start to work.

It also means you would have been able to write decent portable applications with existing technology, and Java wouldn't have been a success because it wouldn't have been necessary. Think how better would things be.

Name: Anonymous 2007-05-08 19:04 ID:UZbxCNCb

>>18
why not just write your own libxbox and use that?
Failure. If I have to write it myself, then I better use a language that comes with a standard library that provides it. Besides, my libxbox is MY libxbox. I would have to port it to 40 platforms if I want it to run in 40 platforms. I would have to maintain it myself. I wouldn't find additional community libraries and utilities written over it. Nobody else would use that. It would bite other libraries. So my libxbox, or your libxbox, or that guy's libxbox is not the best or nicest solution.

>>19
TRE.
I haven't seen that in my standard.

die
Okay, so you don't want a standard network interface. I suppose it's not necessary if all you want to do port FORTRAN 200-liners with complex numbers.

This is C. hardcode or gtfo
So you're in your 15 years old low-level, I-do-it-all, CFLAGS optimized stage. Once you get a life (even a geek life), you'll start putting more value on your time and skills, therefore you won't want to have it wasted by redoing what the world has done 1000000 times before you, 500000 of them better than you would do it.

So wait, remind me what is wrong with 3rd party libraries ?
They are not standard, not portable to all platforms where C exists, not universally available, and fragmented.

Deep inside me, i hope you're a troll.
Deep inside me, I hope you'll overcome your C phase where you try to write everything and never get anything done (by the time your libraries are almost done, you're tired of the project and drop it, am i rite?), and start writing useful open source.

Name: Anonymous 2007-05-08 19:17 ID:orddlkZI

`C' has been obsoleted by `Haskell'. Thread over.

Name: Anonymous 2007-05-08 19:38 ID:uEhc0Lsx

>>22
Haskelled

Name: Anonymous 2007-05-08 21:28 ID:KLbeTdaJ

>>17
Link against a library, fucknut. Or have every last damned elevator controller be bogged down with a 16-megabyte flash chip just so people like you have their precious little "portable threads".

Name: Anonymous 2007-05-08 21:57 ID:GzVIAdO+

Geez. I think >>17 covered it pretty thoroughly.

It's because of such reasons that I moved the low-level work on personal project to something like D. Sockets programming is still more work than it should be, but at least I don't need to write yet another hash or worry about whether the datastreams are 8-bit or not (null-terminated strings are ghey, especially when you have a GC so you can slice).

>>24
Then have an embedded library profile. We should hold back the entire language because of a subset of users?

Name: Anonymous 2007-05-08 23:40 ID:8c9mlFDF

>>17
C isn't java idiot. C is portable assembler. You can't have a language that is small and has huuuuuge useful standard library.

Name: Anonymous 2007-05-08 23:53 ID:GzVIAdO+

>>26
Why not just get rid of the standard library altogether then? lol its tny

Besides, about half of those complaints could be fixed without increasing the library size. As for the rest, use profiles (e.g.: embedded and normal).

Besides, a library is just an group of objects. If your linker or library archiver can't extract only the relevant objects, it fails. How many embedded projects ship with the entire standard C library?

Name: Anonymous 2007-05-09 1:39 ID:Heaven

>>17
unicode, pcre, and threads maybe, the rest fuck no.

Name: Anonymous 2007-05-09 1:58 ID:s9/s3Mjh

>>27
Ever heard about dynamic linking?

Name: Anonymous 2007-05-09 3:02 ID:x5vkKwaU

>>29
Ever heard of preparing your own dynamic library? You want to talk embedded? There you go. Point stands.

However, since we're on the topic, why are things like basic ADT not available in the standard library? You think everyone reinventing the same wheel doesn't increase bugs and code bloat?

Name: Anonymous 2007-05-09 4:38 ID:pR1JNmSE

Programming C is like drinking sand while getting assfucked by a horse.

Name: Anonymous 2007-05-09 6:01 ID:+Vqt+F7r

Oh you guys!

Name: Anonymous 2007-05-09 7:00 ID:/6gbk/BD

>>31
I'm so hardcore i program in C while drinking sand and getting fucked by a doped stallion.

Name: Anonymous 2007-05-09 7:36 ID:bk9FucPQ

>>31
i wanna know the story behind how the fuck you know that!

Name: Anonymous 2007-05-09 7:55 ID:jmLYhFkW

>>33
I'm so hardcore i fuck in C while getting a stallion drunk and programming sand.

Name: Anonymous 2007-05-09 12:36 ID:uWdcA5r0

I'm so sandcore i drink dope while hardening C and getting stalled by a fucking program.

Name: Anonymous 2007-05-09 12:56 ID:pR1JNmSE

>>36 PHP programmer

Name: Anonymous 2007-05-09 12:59 ID:w0llfeAT

i told u i was sandcore

Name: Anonymous 2007-05-09 13:00 ID:uWdcA5r0

>>38

You're so sandcore you eat wolves

Name: Anonymous 2007-05-09 23:06 ID:s9/s3Mjh

>>30
ADTs in the C stdlib sound like a mostly bad idea. That'd be committing the standard library to just one kind of interface, which could end up being totally inappropriate for other sorts of things. The same reasons why you wouldn't want to drag "glib" (i.e. what used to be named the GTK+ utility library) around in every program in every context.

The C stdlib has aged fairly well; contrast to Java, which has had a couple of I/O overhauls already in just a bit over a decade. Really, one of C's greatest strengths is that it's very small compared to other languages of similar or greater standard functionality. Plus, being small it's rather easy to learn and use without having to search a 150-megabyte online reference every five minutes or so.

Name: Anonymous 2007-05-09 23:46 ID:x5vkKwaU

That'd be committing the standard library to just one kind of interface
That's when you'd reinvent a wheel. Right now we're always reinventing the wheel.

I really don't want to be writing (or importing) Yet Another Hash Table anymore. I've done my time, so to speak.

The C stdlib has aged fairly well
To extend the argument, if there was no library, there would be nothing to age. :)

Besides, I disagree to some extent. String handling in particular needs an overhaul.

Plus, being small it's rather easy to learn
That much is true.

Name: Anonymous 2007-05-09 23:47 ID:tdC0Nv94

>>19 ("So wait, remind me what is wrong with 3rd party libraries ?")
Licenses. Either you use a Microsoft compiler (first party, proprietary libraries, non-free GUI compiler) or you face telling your manager that he has to pay for a QT license or whatever else it is that some company created because the standard is too lazy to add stuff that is worth our while. Look at Java's HUEG as in xbox libraries. If C standardized even a quarter of those, we wouldn't have java fanboi-ism, because we could do all the stuff it does without the speed trade-off.

3rd party stuff and licenses cost your job money. And cost you expensive books on training every time the company retools the library or dies.

Name: Anonymous 2007-05-10 0:38 ID:TUTvGr8W

>>42
Or you use libraries that don't have shitty licenses.

Name: Anonymous 2007-05-10 11:44 ID:zaqmWefZ

>>41
There are utility libraries for that sort of thing, as you know. I mentioned "glib" just now; it's even got a sane license on it, and allows for as much ADTey goodness as a C library ever will. (i.e. lots of casting to and from renamed void pointers...)

This way, there's no whining about "why don't you use the standard library ADTs? this is not portable! I don't want to learn yet another library!". I find this a welcome bonus.

Name: Anonymous 2007-05-10 12:42 ID:Heaven

>>44
glib has a sane license?
:checks google:
LGPL is not a sane license.
BSD or MIT or similar or GTFO.

Name: Anonymous 2007-05-10 14:09 ID:Heaven

>>45
Ideology? In _my_ /prog/?

Name: Anonymous 2007-05-10 14:46 ID:Heaven

public domain ftw

Name: Anonymous 2007-05-11 7:12 ID:h5Nj7HeA

The GPL has never been successfully enforced in a court of law, so just enjoy the free code and do what you want with it. And by "free" I mean the conventional sense of the word, not the crap that Stallman made up.

A couple of friends work for a large commercial software house and they stuff plenty of GPL code in the programs. There is virtually no risk and a lot of benefit.

Name: Anonymous 2007-05-11 7:30 ID:JluKkFwB

>>48

"On September 6, 2006 the district court issued its judgement, confirming the
claims by gpl-violations.org, specifically its rights on the subject-matter
source code, the violation of the GNU GPL by D-Link, the validity of the GPL
under German law, and D-Links obligation to reimburse gpl-violations.org for
legal expenses, test purchase and cost of re-engineering."

lawl

Name: Anonymous 2007-05-11 8:00 ID:Heaven

>>48
The GPL has been upheld several times under several jurisdictions.

Name: Anonymous 2007-05-11 8:14 ID:Heaven

NSA can't touch the code for any of the GPL'd software they use, specifically because they'd have to release their changes, which would most likely include secret stuff in it. It's been challenged.

Name: Anonymous 2007-05-11 11:55 ID:DBXl+miH

>>51
Untrue, they are under no obligation to share their code as long as they don't distribute the modified programs.

Also, http://www.nsa.gov/selinux/

Name: Anonymous 2007-05-11 12:37 ID:Heaven

>>52
Interagency distribution counts.

Name: Anonymous 2007-05-11 13:03 ID:GeMUAr/N

You only have to provide the source code to the people you're giving the programs too. Interagency doesn't mean it must be released to the rest of the world, only interagency.

Name: Anonymous 2007-05-11 17:13 ID:QK7mddbe

>>1
Pirate the ISO standard, I've been sharing it in eMule

Name: Anonymous 2007-05-11 17:20 ID:Heaven

>>55
why do that when you can just grab it from http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf?

Name: Anonymous 2007-05-11 17:26 ID:QK7mddbe

>>56
Cause pirating feels good.

Name: Anonymous 2007-05-11 18:14 ID:1Ufe7FYH

Some points I'd agree with on the C standard library:
- Needs threads (boost::thread has these, may become part of C++ standard though)
- Could use networking (SDL_net sucks but it's the only truly cross-platform one I've found)
- Fukken needs unicode or something better than over 9000 incompatible implementations of non-8 bit strings

This stuff keeps me using C++, the boost libraries and the STL are a real boon. It's still not exactly fast to code with.

Name: Anonymous 2007-05-11 19:44 ID:Heaven

>>48
Deriving from software licensed under the GNU GPL is quite all right. The source distribution and licensing bits only kick in when you _distribute_ the actual derived work, whether binary or source.

Last place I worked, we used a GPL'd simple java httpd class in private software. Works a charm, it's never going to be distributed anywhere, everything's cool. Stays on the right side of the GPL, too.

Name: Anonymous 2009-01-14 13:34

Welcome to the botnet

Name: Anonymous 2010-12-17 1:39

Erika once told me that Xarn is a bad boyfriend

Name: Anonymous 2011-02-04 13:10

Name: Sgt.Kabu�ⵠkiman囅ᔯ 2012-05-29 1:29

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List