当用户使用诸如int8_t之类的变量类型时,我试图获得类似“定制”的编译器警告,这可能会导致不良行为(Are int8_t and uint8_t intended to be char types?)。
因此,我想(可选)替换这些变量类型,并在使用它们时添加警告。到目前为止,我的想法是这样的:
header.h
#pragma once
#pragma warning ("int8_t can be interpreted as char - replaced with int16_t")
#define int8_t int16_t
但这不会打印自定义错误消息,也不会为每次替换打印它,而是始终打印一次,无论是否替换了int8_t。
如果您对如何解决此问题有任何建议,我们将不胜感激!