Created
December 15, 2012 03:05
-
-
Save vobject/4291003 to your computer and use it in GitHub Desktop.
Some simple typdef/struct compilation tests in C/C++.
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
/* | |
* Some simple typdef/struct compilation tests. | |
* Tested with gcc4.7 and clang3.1 | |
*/ | |
struct AAA { | |
int a, b, c, d; | |
}; | |
typedef struct _BBB { // Windows header style. | |
int a, b, c, d; | |
} BBB; | |
typedef struct { | |
int a, b, c, d; | |
} CCC; | |
struct DDD { | |
int a, b, c, d; | |
} ddd; | |
struct { | |
int a, b, c, d; | |
} eee; // gcc4.7 compiles but gives warning. | |
// no warning with clang3.1. | |
static struct { | |
int a, b, c, d; | |
} fff; | |
namespace { | |
struct { | |
int a, b, c, d; | |
} ggg; // gcc4.7 compiles but gives warning. | |
// no warning with clang3.1. | |
static struct { | |
int a, b, c, d; | |
} hhh; | |
} | |
typedef struct III { | |
int a, b, c, d; | |
} III; | |
int main() | |
{ | |
struct AAA a0; | |
AAA a1; // Does not compile in C. | |
struct _BBB b0; | |
// struct BBB b0; // Does not compile. | |
BBB b1; | |
// struct CCC c0; // Does not compile. | |
CCC c1; | |
ddd.a = 42; | |
struct DDD d0; | |
DDD d1; // Does not compile in C. | |
eee.a = 0; | |
fff.a = 1; | |
ggg.a = 1; | |
hhh.a = 2; | |
struct III i0; | |
III i1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment