Question: With GCC & Clang you can deprecate `struct` members, (as shown below).

However I didn't see a way to do this for other compilers (MSVC for example).

While this isn't apart of the C spec and most likely relies on pragma's or custom extensions for each compiler, it would be useful to be able to support this across a wider range of compilers.

```
/* mytest.h */
#ifdef __GNUC__
#  define ATTR_DEPRECATED __attribute__((deprecated))
#else
#  define ATTR_DEPRECATED  /* unsupported compiler */
#endif

struct Test {
  int bar;
  int foo  ATTR_DEPRECATED;
};

```

Once a member is deprecated, the compiler should warn of its use if its accessed directly, eg:

```
#include "mytest.h"
static func(void)
{
    Test t;
    t.bar = 1;
    t.foo = 0;  /* <-- WARN ABOUT THIS AT COMPILE TIME */
}

```

Answer: 
Perhaps something more along the lines of this:

```
#ifdef __GNUC__
    #define DEPRECATED(x) x __attribute__((deprecated))
#elif defined _MSC_VER
    #define DEPRECATED(x) __pragma deprecated(x)
#else
    #define DEPRECATED(x) x
#endif

```

edit: this is based on Quirliom's answer
2nd edit: fixed #pragma to be \_\_pragma as suggested by ideasman42
If all of deprecated structure members have names which are unique to the structure, it may be possible to replace the structure with one that contains an array of a structure containing the real values but slightly different names, and then use `#define` to create macros that define all of the structure's elements.

For example, if the old structure was:

```
typedef struct {
  int FOO_first;
  int FOO_second;
  long FOO_third;
} FOO;

```

one could replace it with:

```
#define WARNING_ZERO (2u < -1) // An expression which will yield a constant zero but print a warning

#define FOO_second (FOOO_second[WARNING_ZERO])

typedef struct {
  int FOO_first;
  int FOOO_second[1];
  long FOO_third;
}

```

Unfortunately, I don't know any way to make that technique work in C if the names of any deprecated items are used as identifiers for any other purpose.