forked from thradams/cake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
15 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,18 @@ | ||
extern void puts(const char*); | ||
//#include <stdio.h> | ||
|
||
struct { bool success; int value; } parse(const char* s) | ||
{ | ||
if (s == 0) | ||
return (typeof(parse(0))) { false, 1 }; | ||
|
||
typedef struct {} x86_64; | ||
typedef struct {} i386; | ||
|
||
struct x86_64 { x86_64 type; }; | ||
struct i386 { i386 type; }; | ||
|
||
typedef union { | ||
typeof( | ||
_Generic( | ||
&(char[sizeof sizeof 1]) { 0 }, | ||
char(*)[4]:(struct i386) {}.type, | ||
char(*)[8] : (struct x86_64) {}.type) | ||
) cpu_type; | ||
} arch; | ||
return (typeof(parse(0))) { true, 1 }; | ||
}; | ||
|
||
int main(void) | ||
int main() | ||
{ | ||
puts(_Generic( | ||
(arch*) | ||
auto r = parse("1"); | ||
if (r.success) | ||
{ | ||
0 | ||
}->cpu_type, | ||
x86_64:"x86_64", | ||
i386 : "i386")); | ||
// printf("%d", r.value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.