Skip to content

Instantly share code, notes, and snippets.

@vobject
Created December 15, 2012 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vobject/4291003 to your computer and use it in GitHub Desktop.
Save vobject/4291003 to your computer and use it in GitHub Desktop.
Some simple typdef/struct compilation tests in C/C++.
/*
* 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