GCC options for strictest C code? [duplicate]

I’d recommend using: -Wall -Wextra -std=c89 -pedantic -Wmissing-prototypes -Wstrict-prototypes \ -Wold-style-definition You should compile with -O as well as -g as some warnings are only available when the optimizer is used (actually, I usually use -O3 for spotting the problems). You might prefer -std=gnu89 as that disables fewer extensions in the libraries. OTOH, if you’re … Read more

Convert ISO 8601 to NSDate

This works for me: NSString *dateString = @”2013-04-18T08:49:58.157+0000″; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@”yyyy-MM-dd’T’HH:mm:ss.SSSZ”]; // Always use this locale when parsing fixed format date strings NSLocale *posix = [[NSLocale alloc] initWithLocaleIdentifier:@”en_US_POSIX”]; [formatter setLocale:posix]; NSDate *date = [formatter dateFromString:dateString]; NSLog(@”date = %@”, date);

Why does ISO/IEC charge for the C and C++ standards instead of providing them for free?

For what it’s worth, Herb Sutter wrote an article touching on this issue, and there’s a fair bit of discussion in the comments: http://herbsutter.com/2010/03/03/where-can-you-get-the-iso-c-standard-and-what-does-open-standard-mean/ As he mentions, “open” does not necessarily mean “no-cost”. As far as students or others with limited financial means who might want free versions of thee documents, note that: many references … Read more

What is the __STDC_VERSION__ value for C11?

With -std=c11 in gcc, 201112L is used for __STDC_VERSION__ See this gcc patch on December 20, 2011 on gcc ml: https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg23572.html And note that apparently the ISO version of C11 forgot to update the 201ymmL from the Draft. The intended final __STDC_VERSION__ value, 201112L, is also implemented (the editor forgot to update the 201ymmL placeholders … Read more

What standard do language codes of the form “zh-Hans” belong to?

The current reference for identifying languages is IETF BCP 47, which combines IETF RFC 5646 and RFC 4647. Codes of the form ll-Xxxx combine an ISO 639-1 language code (two letters) and an ISO 15924 script code (four letters). BCP 47 recommends that language codes be written in lower case and that script codes be … Read more

Converting an ISO 8601 timestamp into an NSDate: How does one deal with the UTC time offset?

No need to remove the :’s. To handle the “00:00” style timezone, you just need “ZZZZ”: Swift let dateString = “2014-07-06T07:59:00Z” let dateFormatter = NSDateFormatter() dateFormatter.locale = NSLocale(localeIdentifier: “en_US_POSIX”) dateFormatter.dateFormat = “yyyy-MM-dd’T’HH:mm:ssZZZZ” dateFormatter.dateFromString(dateString) Objective-C NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; dateFormat.locale = [[NSLocale alloc] initWithLocaleIdentifier:@”en_US_POSIX”]; NSString *input = @”2013-05-08T19:03:53+00:00″; [dateFormat setDateFormat:@”yyyy-MM-dd’T’HH:mm:ssZZZZ”]; //iso 8601 format NSDate … Read more

tech