Demo for http://stackoverflow.com/q/16092520/827263
As you can see, g++ 4.7.2 reports the missing semicolon error in c.c, not in foo.h
Demo for http://stackoverflow.com/q/16092520/827263
As you can see, g++ 4.7.2 reports the missing semicolon error in c.c, not in foo.h
| #include <stdio.h> | |
| int main(void) { | |
| FILE *f; | |
| } |
| From nobody Mon Aug 26 10:42:03 2013 | |
| X-Received: by 10.224.13.136 with SMTP id c8mr16375654qaa.0.1377533997489; | |
| Mon, 26 Aug 2013 09:19:57 -0700 (PDT) | |
| X-Received: by 10.50.80.78 with SMTP id p14mr380876igx.6.1377533997453; Mon, | |
| 26 Aug 2013 09:19:57 -0700 (PDT) | |
| Path: eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!fx3no4866766qab.0!news-out.google.com!he10ni3708qab.0!nntp.google.com!fx3no4866762qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail | |
| Newsgroups: comp.lang.c | |
| Date: Mon, 26 Aug 2013 09:19:57 -0700 (PDT) | |
| In-Reply-To: <[email protected]> | |
| Complaints-To: [email protected] |
| #include <iostream> | |
| using namespace std; | |
| int agenext (int age); | |
| int main () | |
| { | |
| int age = 42; | |
| cout << "age = " << age << "\n"; | |
| agenext(age); |
| /* | |
| * Test program based on code in the Wikipedia POSIX Threads | |
| * article, https://en.wikipedia.org/wiki/POSIX_Threads. | |
| * | |
| * Demo for http://stackoverflow.com/q/19128948/827263 | |
| */ | |
| #include <pthread.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <assert.h> |
korn.c is the "Best One Liner" winner of the 1987 International Obfuscated C Code Contest, by David Korn (yes, the author of the Korn Shell).
korn.hint, as the name implies, offers some hints.
A commenter on Stack Overflow asked for some clarification. I didn't want to post spoilers on the site, so I'm posting them here instead. If you haven't already (and if you're familiar with the rules of C) I encourage you to study the program for a while first.
=====
Here's the code:
| /* | |
| * In response to http://stackoverflow.com/a/22918463/827263 | |
| * "In C you can't declare variables/functions (in same scope) with the same name more than once." | |
| */ | |
| #include <stdio.h> | |
| void yes_you_can(void); | |
| void yes_you_can(void); | |
| void yes_you_can(void); |
| #include <stdio.h> | |
| #include <stdint.h> | |
| int main(void) { | |
| int64_t u = 0; | |
| int i; | |
| for(i=0;i<44;i++) | |
| u |= (uint64_t)1 << i; |
Demo for clang bug (demonstrated with version 3.4)
Based on this question on Stack Overflow.
===
It turns out that this isn't a bug; see Jens Gustedt's answer to the question.