Skip to content

Instantly share code, notes, and snippets.

@JonathonReinhart
Created October 15, 2016 23:08
Show Gist options
  • Save JonathonReinhart/b45a5d2db70a9950265fde7f325b37f0 to your computer and use it in GitHub Desktop.
Save JonathonReinhart/b45a5d2db70a9950265fde7f325b37f0 to your computer and use it in GitHub Desktop.
Circular includes
#ifndef A_DOT_H_INCLUDED
#define A_DOT_H_INCLUDED
#include "b.h"
struct a
{
struct b *b;
};
#endif /* A_DOT_H_INCLUDED */
#ifndef B_DOT_H_INCLUDED
#define B_DOT_H_INCLUDED
#include "a.h"
struct b
{
struct a *a;
};
#endif /* B_DOT_H_INCLUDED */
#include "a.h"
int main(void)
{
struct a a;
(void) a;
return 0;
}
@JonathonReinhart
Copy link
Author

$ gcc -Wall -Wextra -Werror main.c  && echo "OK"
OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment