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: 
Put simply, there isn't a one-way fits all thing here. Some compilers simply don't support such ideas. I will suggest something along the lines of [this](https://stackoverflow.com/a/5488477/1702990) however, duplicated here (with some modification):

```
#ifdef __GNUC__
   #define ATTR_DEPRECATED __attribute__((deprecated))
#elif defined _MSC_VER
   //List of deprecated values
   #pragma deprecated(values)
#endif

```

Unfortunately, this requires a `#pragma` line for every deprecated member but hey.
Also, as ideasman points out in the comments, the `deprecated` pragma is global, so if you have an instance with the same name as your struct member anywhere, it will be marked.
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.