title: Prevent or generate warning for custom deprecations
body: <p>I'm using C++11's <code>static_assert</code> to perform compile-time checks to prevent the use of insecure functions, and/or to provide feedback to the user when a new feature should be used and the relevant APIs are out of date (e.g. using <code>std::strftime</code>, <code>std::to_string</code>, etc.).</p>
  
  <p>I want to force failure if any source code attempts to use outdated functions, but I need it to be totally cross-platform, and also bypass or workaround other 'helpers' such as Microsofts own deprecations.</p>
  
  <p>I see I can use .sections when working with a gnu toolchain, which I can see the definition for in OpenBSD's cdefs.h (<a href="http://ninjalj.blogspot.co.uk/2011/11/your-own-linker-warnings-using-gnu.html" rel="nofollow noreferrer">http://ninjalj.blogspot.co.uk/2011/11/your-own-linker-warnings-using-gnu.html</a>) but I have nothing equivalent for Visual Studio.</p>
  
  <p>For example, I can use the following code without a problem to prevent <code>strcpy</code>/<code>strcat</code>:</p>
  
  <pre><code>#   define COMPILE_TIME_CHECK(expression, message)      static_assert(expression, message)
  #   define GUARANTEE_FAILURE            (0 == 1)
  #   define DISABLED_FUNCTIONS_MESSAGE_CSTRING   "strcpy, strcat must be replaced with strlcpy and strlcat, respectively"
  #   define strcat       COMPILE_TIME_CHECK(GUARANTEE_FAILURE, DISABLED_FUNCTIONS_MESSAGE_CSTRING);
  </code></pre>
  
  <p>it may be unclean but works; but the trouble is when attempting to do the same with others that don't play as nicely, such as <code>ctime</code> and <code>localtime</code>:</p>
  
  <pre><code>_CRT_INSECURE_DEPRECATE(localtime_s) static __inline struct tm * __CRTDECL localtime(const time_t * _Time)
  
  1&gt;c:\program files (x86)\microsoft visual studio 12.0\vc\include\time.inl(86): error C2059: syntax error : 'static_assert'
  </code></pre>
  
  <p>Is there a way I can block specific functions (warning or compile failure), while providing a message for what to use in their place, without conflict from gcc/visual studio in a suitable way? The CRT macros in visual studio do not prevent the above error with the aforementioned defines.</p>
  
  <p>I'm not convinced something like <code>__declspec(deprecated) int strcpy(char*,char*);</code> (as noted here: <a href="https://stackoverflow.com/questions/295120/c-mark-as-deprecated">C++ mark as deprecated</a>) is going to always play ball, and is a lot more work &amp; less descriptive than just setting a define for the function name.</p>