This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients loewis, martin.panter, ned.deily, rhettinger, serhiy.storchaka, vstinner, xiang.zhang
Date 2016-04-22.08:17:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461313065.01.0.548513976392.issue26824@psf.upfronthosting.co.za>
In-reply-to
Content
It is possible to implement type checking in C macros.

Example found on the Internet:

/* inline type checking - can mix in with other macros more easily using the comma operator,
 * C11 gives best results here */
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#  define CHECK_TYPE_INLINE(val, type) \
    (void)((void)(((type)0) != (0 ? (val) : ((type)0))), \
           _Generic((val), type: 0, const type: 0))
#else
#  define CHECK_TYPE_INLINE(val, type) \
    ((void)(((type)0) != (0 ? (val) : ((type)0))))
#endif

http://stackoverflow.com/questions/11449632/checking-types-of-macro-parameters-at-compile-time

See also Include/pymacro.h which contains some macros implementing checks tested at the compilation.
History
Date User Action Args
2016-04-22 08:17:45vstinnersetrecipients: + vstinner, loewis, rhettinger, ned.deily, martin.panter, serhiy.storchaka, xiang.zhang
2016-04-22 08:17:45vstinnersetmessageid: <1461313065.01.0.548513976392.issue26824@psf.upfronthosting.co.za>
2016-04-22 08:17:45vstinnerlinkissue26824 messages
2016-04-22 08:17:44vstinnercreate